Home | History | Annotate | Download | only in layers
      1 /* Copyright (c) 2015-2016 The Khronos Group Inc.
      2  * Copyright (c) 2015-2016 Valve Corporation
      3  * Copyright (c) 2015-2016 LunarG, Inc.
      4  *
      5  * Permission is hereby granted, free of charge, to any person obtaining a copy
      6  * of this software and/or associated documentation files (the "Materials"), to
      7  * deal in the Materials without restriction, including without limitation the
      8  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
      9  * sell copies of the Materials, and to permit persons to whom the Materials
     10  * are furnished to do so, subject to the following conditions:
     11  *
     12  * The above copyright notice(s) and this permission notice shall be included
     13  * in all copies or substantial portions of the Materials.
     14  *
     15  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
     18  *
     19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
     20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
     21  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE
     22  * USE OR OTHER DEALINGS IN THE MATERIALS
     23  *
     24  * Author: Tobin Ehlis <tobin (at) lunarg.com>
     25  * Author: Mark Lobodzinski <mark (at) lunarg.com>
     26  */
     27 
     28 #include "vulkan/vk_layer.h"
     29 #include <vector>
     30 
     31 using namespace std;
     32 
     33 // Device Limits ERROR codes
     34 typedef enum _DEV_LIMITS_ERROR {
     35     DEVLIMITS_NONE,                          // Used for INFO & other non-error messages
     36     DEVLIMITS_INVALID_INSTANCE,              // Invalid instance used
     37     DEVLIMITS_INVALID_PHYSICAL_DEVICE,       // Invalid physical device used
     38     DEVLIMITS_INVALID_INHERITED_QUERY,       // Invalid use of inherited query
     39     DEVLIMITS_MUST_QUERY_COUNT,              // Failed to make initial call to an API to query the count
     40     DEVLIMITS_MUST_QUERY_PROPERTIES,         // Failed to make initial call to an API to query properties
     41     DEVLIMITS_INVALID_CALL_SEQUENCE,         // Flag generic case of an invalid call sequence by the app
     42     DEVLIMITS_INVALID_FEATURE_REQUESTED,     // App requested a feature not supported by physical device
     43     DEVLIMITS_COUNT_MISMATCH,                // App requesting a count value different than actual value
     44     DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST,  // Invalid queue requested based on queue family properties
     45     DEVLIMITS_LIMITS_VIOLATION,              // Driver-specified limits/properties were exceeded
     46     DEVLIMITS_INVALID_UNIFORM_BUFFER_OFFSET, // Uniform buffer offset violates device limit granularity
     47     DEVLIMITS_INVALID_STORAGE_BUFFER_OFFSET, // Storage buffer offset violates device limit granularity
     48 } DEV_LIMITS_ERROR;
     49 
     50 typedef enum _CALL_STATE {
     51     UNCALLED,      // Function has not been called
     52     QUERY_COUNT,   // Function called once to query a count
     53     QUERY_DETAILS, // Function called w/ a count to query details
     54 } CALL_STATE;
     55 
     56 typedef struct _INSTANCE_STATE {
     57     // Track the call state and array size for physical devices
     58     CALL_STATE vkEnumeratePhysicalDevicesState;
     59     uint32_t physicalDevicesCount;
     60     _INSTANCE_STATE() : vkEnumeratePhysicalDevicesState(UNCALLED), physicalDevicesCount(0){};
     61 } INSTANCE_STATE;
     62 
     63 typedef struct _PHYSICAL_DEVICE_STATE {
     64     // Track the call state and array sizes for various query functions
     65     CALL_STATE vkGetPhysicalDeviceQueueFamilyPropertiesState;
     66     uint32_t queueFamilyPropertiesCount;
     67     CALL_STATE vkGetPhysicalDeviceLayerPropertiesState;
     68     uint32_t deviceLayerCount;
     69     CALL_STATE vkGetPhysicalDeviceExtensionPropertiesState;
     70     uint32_t deviceExtensionCount;
     71     CALL_STATE vkGetPhysicalDeviceFeaturesState;
     72     _PHYSICAL_DEVICE_STATE()
     73         : vkGetPhysicalDeviceQueueFamilyPropertiesState(UNCALLED), queueFamilyPropertiesCount(0),
     74           vkGetPhysicalDeviceLayerPropertiesState(UNCALLED), deviceLayerCount(0),
     75           vkGetPhysicalDeviceExtensionPropertiesState(UNCALLED), deviceExtensionCount(0),
     76           vkGetPhysicalDeviceFeaturesState(UNCALLED){};
     77 } PHYSICAL_DEVICE_STATE;
     78