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 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * Author: Tobin Ehlis <tobin@lunarg.com>
18 * Author: Mark Lobodzinski <mark@lunarg.com>
19 */
20
21#include "vulkan/vk_layer.h"
22#include <vector>
23
24using namespace std;
25
26// Device Limits ERROR codes
27enum DEV_LIMITS_ERROR {
28    DEVLIMITS_NONE,                          // Used for INFO & other non-error messages
29    DEVLIMITS_INVALID_INSTANCE,              // Invalid instance used
30    DEVLIMITS_INVALID_PHYSICAL_DEVICE,       // Invalid physical device used
31    DEVLIMITS_INVALID_INHERITED_QUERY,       // Invalid use of inherited query
32    DEVLIMITS_INVALID_ATTACHMENT_COUNT,      // Invalid value for the number of attachments
33    DEVLIMITS_MUST_QUERY_COUNT,              // Failed to make initial call to an API to query the count
34    DEVLIMITS_INVALID_CALL_SEQUENCE,         // Flag generic case of an invalid call sequence by the app
35    DEVLIMITS_INVALID_FEATURE_REQUESTED,     // App requested a feature not supported by physical device
36    DEVLIMITS_COUNT_MISMATCH,                // App requesting a count value different than actual value
37    DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST,  // Invalid queue requested based on queue family properties
38    DEVLIMITS_INVALID_UNIFORM_BUFFER_OFFSET, // Uniform buffer offset violates device limit granularity
39    DEVLIMITS_INVALID_STORAGE_BUFFER_OFFSET, // Storage buffer offset violates device limit granularity
40    DEVLIMITS_INVALID_BUFFER_UPDATE_ALIGNMENT,  // Alignment requirement for buffer update is violated
41};
42
43enum CALL_STATE{
44    UNCALLED,      // Function has not been called
45    QUERY_COUNT,   // Function called once to query a count
46    QUERY_DETAILS, // Function called w/ a count to query details
47};
48
49struct INSTANCE_STATE {
50    // Track the call state and array size for physical devices
51    CALL_STATE vkEnumeratePhysicalDevicesState;
52    uint32_t physicalDevicesCount;
53    INSTANCE_STATE() : vkEnumeratePhysicalDevicesState(UNCALLED), physicalDevicesCount(0){};
54};
55
56struct PHYSICAL_DEVICE_STATE {
57    // Track the call state and array sizes for various query functions
58    CALL_STATE vkGetPhysicalDeviceQueueFamilyPropertiesState;
59    uint32_t queueFamilyPropertiesCount;
60    CALL_STATE vkGetPhysicalDeviceLayerPropertiesState;
61    uint32_t deviceLayerCount;
62    CALL_STATE vkGetPhysicalDeviceExtensionPropertiesState;
63    uint32_t deviceExtensionCount;
64    CALL_STATE vkGetPhysicalDeviceFeaturesState;
65    PHYSICAL_DEVICE_STATE()
66        : vkGetPhysicalDeviceQueueFamilyPropertiesState(UNCALLED), queueFamilyPropertiesCount(0),
67          vkGetPhysicalDeviceLayerPropertiesState(UNCALLED), deviceLayerCount(0),
68          vkGetPhysicalDeviceExtensionPropertiesState(UNCALLED), deviceExtensionCount(0),
69          vkGetPhysicalDeviceFeaturesState(UNCALLED){};
70};
71