ScreenShot: Update extension and layer support
authorCourtney Goeltzenleuchter <courtney@LunarG.com>
Tue, 7 Jul 2015 17:25:43 +0000 (11:25 -0600)
committerCourtney Goeltzenleuchter <courtney@LunarG.com>
Tue, 7 Jul 2015 23:57:49 +0000 (17:57 -0600)
layers/CMakeLists.txt
layers/screenshot.cpp

index d4170c9dc14e62fe2b80570830183c9242a554b1..85b25a1863cb87fe3c5fcc4c8f1283d7930293d0 100644 (file)
@@ -102,7 +102,7 @@ add_vk_layer(MemTracker mem_tracker.cpp vk_layer_table.cpp)
 add_vk_layer(ShaderChecker shader_checker.cpp vk_layer_table.cpp)
 add_vk_layer(Image image.cpp vk_layer_table.cpp)
 add_vk_layer(ParamChecker param_checker.cpp vk_layer_debug_marker_table.cpp vk_layer_table.cpp)
-#add_vk_layer(ScreenShot screenshot.cpp vk_layer_table.cpp)
+add_vk_layer(ScreenShot screenshot.cpp vk_layer_table.cpp)
 # generated
 #add_vk_layer(Generic generic_layer.cpp vk_layer_table.cpp)
 add_vk_layer(APIDump api_dump.cpp vk_layer_table.cpp)
index 12f3d45f3f698cad9429f472ac53607f5c3ddf41..5b8c098444259f5a6b64d75f38835d9d23c1302b 100644 (file)
@@ -45,6 +45,7 @@ using namespace std;
 // being used:
 #include "vk_loader_platform.h"
 #include "vk_layer_table.h"
+#include "vk_layer_extension_utils.h"
 
 
 struct devExts {
@@ -275,7 +276,7 @@ static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo
     VkLayerDispatchTable *pDisp  = get_dispatch_table(screenshot_device_table_map, device);
     deviceExtMap[pDisp].wsi_lunarg_enabled = false;
     for (i = 0; i < pCreateInfo->extensionCount; i++) {
-        if (strcmp(pCreateInfo->pEnabledExtensions[i].name, VK_WSI_LUNARG_EXTENSION_NAME) == 0)
+        if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_WSI_LUNARG_EXTENSION_NAME) == 0)
             deviceExtMap[pDisp].wsi_lunarg_enabled = true;
     }
 }
@@ -298,55 +299,51 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(
 
 /* TODO: Probably need a DestroyDevice as well */
 
-#define SCREENSHOT_LAYER_EXT_ARRAY_SIZE 2
-static const VkExtensionProperties ssExts[SCREENSHOT_LAYER_EXT_ARRAY_SIZE] = {
+static const VkLayerProperties ss_device_layers[] = {
     {
-        VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES,
         "ScreenShot",
-        0x10,
+        VK_API_VERSION,
+        VK_MAKE_VERSION(0, 1, 0),
         "Layer: ScreenShot",
     }
-
 };
-VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionCount(
-        uint32_t*    pCount)
-{
-    *pCount = SCREENSHOT_LAYER_EXT_ARRAY_SIZE;
-    return VK_SUCCESS;
-}
 
 VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionProperties(
-        uint32_t extensionIndex,
-        VkExtensionProperties*    pProperties)
+        const char *pLayerName,
+        uint32_t *pCount,
+        VkExtensionProperties* pProperties)
 {
-    /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */
-    if (extensionIndex >= SCREENSHOT_LAYER_EXT_ARRAY_SIZE)
-        return VK_ERROR_INVALID_VALUE;
-
-    memcpy(pProperties, &ssExts[extensionIndex], sizeof(VkExtensionProperties));
-
-    return VK_SUCCESS;
+    /* ScreenShot does not have any global extensions */
+    return util_GetExtensionProperties(0, NULL, pCount, pProperties);
 }
-VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionCount(
-                                               VkPhysicalDevice gpu,
-                                               uint32_t* pCount)
+
+VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalLayerProperties(
+        uint32_t *pCount,
+        VkLayerProperties*    pProperties)
 {
-    *pCount = SCREENSHOT_LAYER_EXT_ARRAY_SIZE;
-    return VK_SUCCESS;
+    /* ScreenShot does not have any global layers */
+    return util_GetLayerProperties(0, NULL,
+                                   pCount, pProperties);
 }
 
 VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionProperties(
-                                               VkPhysicalDevice gpu,
-                                               uint32_t extensionIndex,
-                                               VkExtensionProperties* pProperties)
+        VkPhysicalDevice                            physicalDevice,
+        const char*                                 pLayerName,
+        uint32_t*                                   pCount,
+        VkExtensionProperties*                      pProperties)
 {
-    /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */
-
-    if (extensionIndex >= SCREENSHOT_LAYER_EXT_ARRAY_SIZE)
-        return VK_ERROR_INVALID_VALUE;
-    memcpy(pProperties, &ssExts[extensionIndex], sizeof(VkExtensionProperties));
+    /* ScreenShot does not have any physical device extensions */
+    return util_GetExtensionProperties(0, NULL, pCount, pProperties);
+}
 
-    return VK_SUCCESS;
+VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceLayerProperties(
+        VkPhysicalDevice                            physicalDevice,
+        uint32_t*                                   pCount,
+        VkLayerProperties*                          pProperties)
+{
+    return util_GetLayerProperties(ARRAY_SIZE(ss_device_layers),
+                                   ss_device_layers,
+                                   pCount, pProperties);
 }
 
 VK_LAYER_EXPORT VkResult VKAPI vkGetDeviceQueue(
@@ -527,8 +524,6 @@ VK_LAYER_EXPORT void* VKAPI vkGetDeviceProcAddr(
     VkDevice         dev,
     const char       *funcName)
 {
-    void *fptr;
-
     if (dev == NULL) {
         return NULL;
     }
@@ -544,18 +539,6 @@ VK_LAYER_EXPORT void* VKAPI vkGetDeviceProcAddr(
     if (!strcmp(funcName, "vkGetDeviceQueue"))
         return (void*) vkGetDeviceQueue;
 
-    if (!strcmp(funcName, "vkGetGlobalExtensionCount"))
-        return (void*) vkGetGlobalExtensionCount;
-
-    if (!strcmp(funcName, "vkGetPhysicalDeviceExtensionCount"))
-        return (void*) vkGetPhysicalDeviceExtensionCount;
-
-    if (!strcmp(funcName, "vkGetGlobalExtensionProperties"))
-        return (void*) vkGetGlobalExtensionProperties;
-
-    if (!strcmp(funcName, "vkGetPhysicalDeviceExtensionProperties"))
-        return (void*) vkGetPhysicalDeviceExtensionProperties;
-
     VkLayerDispatchTable *pDisp =  get_dispatch_table(screenshot_device_table_map, dev);
     if (deviceExtMap.size() == 0 || deviceExtMap[pDisp].wsi_lunarg_enabled)
     {
@@ -571,4 +554,3 @@ VK_LAYER_EXPORT void* VKAPI vkGetDeviceProcAddr(
         return NULL;
     return pDisp->GetDeviceProcAddr(dev, funcName);
 }
-