aboutsummaryrefslogtreecommitdiff
path: root/layers/device_limits.h
blob: 944d5b7188f47e09236c5b18c0b7eba89df82362 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 *
 * Copyright (C) 2015 Valve Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 * Author: Tobin Ehlis <tobin@lunarg.com>
 */
#include "vulkan/vk_layer.h"
#include <vector>
#include "vulkan/vk_ext_debug_report.h"

using namespace std;

// Device Limits ERROR codes
typedef enum _DEV_LIMITS_ERROR
{
    DEVLIMITS_NONE,                             // Used for INFO & other non-error messages
    DEVLIMITS_INVALID_INSTANCE,                 // Invalid instance used
    DEVLIMITS_INVALID_PHYSICAL_DEVICE,          // Invalid physical device used
    DEVLIMITS_MUST_QUERY_COUNT,                 // Failed to make initial call to an API to query the count
    DEVLIMITS_MUST_QUERY_PROPERTIES,            // Failed to make initial call to an API to query properties
    DEVLIMITS_INVALID_CALL_SEQUENCE,            // Flag generic case of an invalid call sequence by the app
    DEVLIMITS_INVALID_FEATURE_REQUESTED,        // App requested a feature not supported by physical device
    DEVLIMITS_COUNT_MISMATCH,                   // App requesting a count value different than actual value
    DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST,     // Invalid queue requested based on queue family properties
    DEVLIMITS_LIMITS_VIOLATION,                 // Driver-specified limits/properties were exceeded
} DEV_LIMITS_ERROR;

typedef enum _CALL_STATE
{
    UNCALLED,       // Function has not been called
    QUERY_COUNT,    // Function called once to query a count
    QUERY_DETAILS,  // Function called w/ a count to query details
} CALL_STATE;

typedef struct _INSTANCE_STATE
{
    // Track the call state and array size for physical devices
    CALL_STATE vkEnumeratePhysicalDevicesState;
    uint32_t physicalDevicesCount;
    _INSTANCE_STATE():vkEnumeratePhysicalDevicesState(UNCALLED), physicalDevicesCount(0) {};
} INSTANCE_STATE;

typedef struct _PHYSICAL_DEVICE_STATE
{
    // Track the call state and array sizes for various query functions
    CALL_STATE vkGetPhysicalDeviceQueueFamilyPropertiesState;
    uint32_t queueFamilyPropertiesCount;
    CALL_STATE vkGetPhysicalDeviceLayerPropertiesState;
    uint32_t deviceLayerCount;
    CALL_STATE vkGetPhysicalDeviceExtensionPropertiesState;
    uint32_t deviceExtensionCount;
    CALL_STATE vkGetPhysicalDeviceFeaturesState;
    _PHYSICAL_DEVICE_STATE():vkGetPhysicalDeviceQueueFamilyPropertiesState(UNCALLED), queueFamilyPropertiesCount(0),
                             vkGetPhysicalDeviceLayerPropertiesState(UNCALLED), deviceLayerCount(0),
                             vkGetPhysicalDeviceExtensionPropertiesState(UNCALLED), deviceExtensionCount(0),
                             vkGetPhysicalDeviceFeaturesState(UNCALLED) {};
} PHYSICAL_DEVICE_STATE;