aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Elliott <ian@LunarG.com>2015-04-21 16:41:02 -0600
committerIan Elliott <ian@LunarG.com>2015-05-15 17:41:11 -0600
commite4602cd9e6cc3a806338c6a06c8ef77a4175076f (patch)
tree7836495049c9dd7bd5d892ac47f368635278dd92
parent4d0b66f936c27ff7592b3def08d1a6cc30db4379 (diff)
downloadusermoji-e4602cd9e6cc3a806338c6a06c8ef77a4175076f.tar.xz
wsi: Add queries for VkDisplayWSI's and VkFormat's to demos.
Show how to query which VkFormat to use for a WSI swap chain. In order to work correctly, changes are needed to existing ICDs: - Changed the order of VkFormats for the intel sample driver, so that the desired value will be first (which is what the demos will use). - Enhanced the nulldrv to support the VK_PHYSICAL_DEVICE_INFO_TYPE_DISPLAY_PROPERTIES_WSI query.
-rw-r--r--demos/cube.c29
-rw-r--r--demos/tri.c30
-rw-r--r--icd/nulldrv/nulldrv.c18
-rw-r--r--icd/nulldrv/nulldrv.h5
4 files changed, 80 insertions, 2 deletions
diff --git a/demos/cube.c b/demos/cube.c
index 9784e680..4406911f 100644
--- a/demos/cube.c
+++ b/demos/cube.c
@@ -294,6 +294,8 @@ struct demo {
int width, height;
VkFormat format;
+ VkDisplayPropertiesWSI *display_props;
+ int num_displays;
VkSwapChainWSI swap_chain;
struct {
VkImage image;
@@ -584,6 +586,7 @@ static void demo_prepare_buffers(struct demo *demo)
.pNext = NULL,
.pNativeWindowSystemHandle = demo->connection,
.pNativeWindowHandle = (void *) (intptr_t) demo->window,
+ .displayCount = 1,
.imageCount = DEMO_BUFFER_COUNT,
.imageFormat = demo->format,
.imageExtent = {
@@ -1965,6 +1968,31 @@ static void demo_init_vk(struct demo *demo)
0, &demo->queue);
assert(!err);
+
+ // Get the VkDisplayWSI's associated with this physical device:
+ VkDisplayWSI display;
+ err = vkGetPhysicalDeviceInfo(demo->gpu, VK_PHYSICAL_DEVICE_INFO_TYPE_DISPLAY_PROPERTIES_WSI,
+ &data_size, NULL);
+ assert(!err);
+ demo->display_props = (VkDisplayPropertiesWSI *) malloc(data_size);
+ err = vkGetPhysicalDeviceInfo(demo->gpu, VK_PHYSICAL_DEVICE_INFO_TYPE_DISPLAY_PROPERTIES_WSI,
+ &data_size, demo->display_props);
+ assert(!err);
+ demo->num_displays = data_size / sizeof(VkDisplayPropertiesWSI);
+ // For now, simply use the first display (TODO: Enhance this for the
+ // future):
+ display = demo->display_props[0].display;
+
+ // Get a VkFormat to use with the VkDisplayWSI we are using:
+ err = vkGetDisplayInfoWSI(display, VK_DISPLAY_INFO_TYPE_FORMAT_PROPERTIES_WSI,
+ &data_size, NULL);
+ VkDisplayFormatPropertiesWSI* display_format_props =
+ (VkDisplayFormatPropertiesWSI*) malloc(data_size);
+ err = vkGetDisplayInfoWSI(display, VK_DISPLAY_INFO_TYPE_FORMAT_PROPERTIES_WSI,
+ &data_size, display_format_props);
+ // For now, simply use the first VkFormat (TODO: Enhance this for the
+ // future):
+ demo->format = display_format_props[0].swapChainFormat;
}
static void demo_init_connection(struct demo *demo)
@@ -2019,7 +2047,6 @@ static void demo_init(struct demo *demo, int argc, char **argv)
demo->width = 500;
demo->height = 500;
- demo->format = VK_FORMAT_B8G8R8A8_UNORM;
demo->spin_angle = 0.01f;
demo->spin_increment = 0.01f;
diff --git a/demos/tri.c b/demos/tri.c
index 625036b8..18f420ce 100644
--- a/demos/tri.c
+++ b/demos/tri.c
@@ -118,6 +118,8 @@ struct demo {
int width, height;
VkFormat format;
+ VkDisplayPropertiesWSI *display_props;
+ int num_displays;
VkSwapChainWSI swap_chain;
struct {
VkImage image;
@@ -380,6 +382,7 @@ static void demo_prepare_buffers(struct demo *demo)
.pNext = NULL,
.pNativeWindowSystemHandle = demo->connection,
.pNativeWindowHandle = (void *) (intptr_t) demo->window,
+ .displayCount = 1,
.imageCount = DEMO_BUFFER_COUNT,
.imageFormat = demo->format,
.imageExtent = {
@@ -1460,6 +1463,32 @@ static void demo_init_vk(struct demo *demo)
err = vkGetDeviceQueue(demo->device, demo->graphics_queue_node_index,
0, &demo->queue);
assert(!err);
+
+
+ // Get the VkDisplayWSI's associated with this physical device:
+ VkDisplayWSI display;
+ err = vkGetPhysicalDeviceInfo(demo->gpu, VK_PHYSICAL_DEVICE_INFO_TYPE_DISPLAY_PROPERTIES_WSI,
+ &data_size, NULL);
+ assert(!err);
+ demo->display_props = (VkDisplayPropertiesWSI *) malloc(data_size);
+ err = vkGetPhysicalDeviceInfo(demo->gpu, VK_PHYSICAL_DEVICE_INFO_TYPE_DISPLAY_PROPERTIES_WSI,
+ &data_size, demo->display_props);
+ assert(!err);
+ demo->num_displays = data_size / sizeof(VkDisplayPropertiesWSI);
+ // For now, simply use the first display (TODO: Enhance this for the
+ // future):
+ display = demo->display_props[0].display;
+
+ // Get a VkFormat to use with the VkDisplayWSI we are using:
+ err = vkGetDisplayInfoWSI(display, VK_DISPLAY_INFO_TYPE_FORMAT_PROPERTIES_WSI,
+ &data_size, NULL);
+ VkDisplayFormatPropertiesWSI* display_format_props =
+ (VkDisplayFormatPropertiesWSI*) malloc(data_size);
+ err = vkGetDisplayInfoWSI(display, VK_DISPLAY_INFO_TYPE_FORMAT_PROPERTIES_WSI,
+ &data_size, display_format_props);
+ // For now, simply use the first VkFormat (TODO: Enhance this for the
+ // future):
+ demo->format = display_format_props[0].swapChainFormat;
}
static void demo_init_connection(struct demo *demo)
@@ -1523,7 +1552,6 @@ static void demo_init(struct demo *demo, const int argc, const char *argv[])
demo->width = 300;
demo->height = 300;
- demo->format = VK_FORMAT_B8G8R8A8_UNORM;
}
static void demo_cleanup(struct demo *demo)
diff --git a/icd/nulldrv/nulldrv.c b/icd/nulldrv/nulldrv.c
index d6472c85..bc30671b 100644
--- a/icd/nulldrv/nulldrv.c
+++ b/icd/nulldrv/nulldrv.c
@@ -1472,6 +1472,24 @@ ICD_EXPORT VkResult VKAPI vkGetPhysicalDeviceInfo(
NULLDRV_LOG_FUNC;
VkResult ret = VK_SUCCESS;
+ if (infoType == VK_PHYSICAL_DEVICE_INFO_TYPE_DISPLAY_PROPERTIES_WSI) {
+ // NOTE: Handle this extension value as a special case:
+ struct nulldrv_display *display;
+ VkDisplayPropertiesWSI *props =
+ (VkDisplayPropertiesWSI *) pData;
+ *pDataSize = sizeof(VkDisplayPropertiesWSI);
+ if (pData == NULL) {
+ return ret;
+ }
+ display = (struct nulldrv_display *) nulldrv_base_create(NULL, sizeof(*display),
+ /*VK_OBJECT_TYPE_SWAP_CHAIN_WSI*//* FIXME: DELETE THIS HACK: */VK_DBG_OBJECT_QUEUE);
+ props->display = (VkDisplayWSI) display;
+ props->physicalResolution.width = 1920;
+ props->physicalResolution.height = 1080;
+
+ return ret;
+ }
+
switch (infoType) {
case VK_PHYSICAL_DEVICE_INFO_TYPE_PROPERTIES:
{
diff --git a/icd/nulldrv/nulldrv.h b/icd/nulldrv/nulldrv.h
index e40ada30..7e15d3b5 100644
--- a/icd/nulldrv/nulldrv.h
+++ b/icd/nulldrv/nulldrv.h
@@ -200,6 +200,11 @@ struct nulldrv_buf_view {
uint32_t cmd_len;
};
+struct nulldrv_display {
+ struct nulldrv_base base;
+ struct nulldrv_dev *dev;
+};
+
struct nulldrv_swap_chain {
struct nulldrv_base base;
struct nulldrv_dev *dev;