forked from KhronosGroup/Vulkan-ValidationLayers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevice_state.h
147 lines (131 loc) · 7.19 KB
/
device_state.h
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/* Copyright (c) 2015-2021 The Khronos Group Inc.
* Copyright (c) 2015-2021 Valve Corporation
* Copyright (c) 2015-2021 LunarG, Inc.
* Copyright (C) 2015-2021 Google Inc.
* Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author: Courtney Goeltzenleuchter <[email protected]>
* Author: Tobin Ehlis <[email protected]>
* Author: Chris Forbes <[email protected]>
* Author: Mark Lobodzinski <[email protected]>
* Author: Dave Houlton <[email protected]>
* Author: John Zulauf <[email protected]>
* Author: Tobias Hector <[email protected]>
*/
#pragma once
#include "base_node.h"
#include <vector>
struct DeviceFeatures {
VkPhysicalDeviceFeatures core;
VkPhysicalDeviceVulkan11Features core11;
VkPhysicalDeviceVulkan12Features core12;
VkPhysicalDeviceExclusiveScissorFeaturesNV exclusive_scissor;
VkPhysicalDeviceShadingRateImageFeaturesNV shading_rate_image;
VkPhysicalDeviceMeshShaderFeaturesNV mesh_shader;
VkPhysicalDeviceInlineUniformBlockFeaturesEXT inline_uniform_block;
VkPhysicalDeviceTransformFeedbackFeaturesEXT transform_feedback_features;
VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT vtx_attrib_divisor_features;
VkPhysicalDeviceBufferDeviceAddressFeaturesEXT buffer_device_address_ext;
VkPhysicalDeviceCooperativeMatrixFeaturesNV cooperative_matrix_features;
VkPhysicalDeviceComputeShaderDerivativesFeaturesNV compute_shader_derivatives_features;
VkPhysicalDeviceFragmentShaderBarycentricFeaturesNV fragment_shader_barycentric_features;
VkPhysicalDeviceShaderImageFootprintFeaturesNV shader_image_footprint_features;
VkPhysicalDeviceFragmentShaderInterlockFeaturesEXT fragment_shader_interlock_features;
VkPhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT demote_to_helper_invocation_features;
VkPhysicalDeviceTexelBufferAlignmentFeaturesEXT texel_buffer_alignment_features;
VkPhysicalDevicePipelineExecutablePropertiesFeaturesKHR pipeline_exe_props_features;
VkPhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV dedicated_allocation_image_aliasing_features;
VkPhysicalDevicePerformanceQueryFeaturesKHR performance_query_features;
VkPhysicalDeviceCoherentMemoryFeaturesAMD device_coherent_memory_features;
VkPhysicalDeviceYcbcrImageArraysFeaturesEXT ycbcr_image_array_features;
VkPhysicalDeviceRayQueryFeaturesKHR ray_query_features;
VkPhysicalDeviceRayTracingPipelineFeaturesKHR ray_tracing_pipeline_features;
VkPhysicalDeviceAccelerationStructureFeaturesKHR ray_tracing_acceleration_structure_features;
VkPhysicalDeviceRobustness2FeaturesEXT robustness2_features;
VkPhysicalDeviceFragmentDensityMapFeaturesEXT fragment_density_map_features;
VkPhysicalDeviceFragmentDensityMap2FeaturesEXT fragment_density_map2_features;
VkPhysicalDeviceASTCDecodeFeaturesEXT astc_decode_features;
VkPhysicalDeviceCustomBorderColorFeaturesEXT custom_border_color_features;
VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT pipeline_creation_cache_control_features;
VkPhysicalDeviceExtendedDynamicStateFeaturesEXT extended_dynamic_state_features;
VkPhysicalDeviceMultiviewFeatures multiview_features;
VkPhysicalDevicePortabilitySubsetFeaturesKHR portability_subset_features;
VkPhysicalDeviceFragmentShadingRateFeaturesKHR fragment_shading_rate_features;
VkPhysicalDeviceShaderIntegerFunctions2FeaturesINTEL shader_integer_functions2_features;
VkPhysicalDeviceShaderSMBuiltinsFeaturesNV shader_sm_builtins_feature;
VkPhysicalDeviceShaderAtomicFloatFeaturesEXT shader_atomic_float_feature;
VkPhysicalDeviceShaderImageAtomicInt64FeaturesEXT shader_image_atomic_int64_feature;
VkPhysicalDeviceShaderClockFeaturesKHR shader_clock_feature;
VkPhysicalDeviceConditionalRenderingFeaturesEXT conditional_rendering;
VkPhysicalDeviceWorkgroupMemoryExplicitLayoutFeaturesKHR workgroup_memory_explicit_layout_features;
VkPhysicalDeviceSynchronization2FeaturesKHR synchronization2_features;
VkPhysicalDeviceExtendedDynamicState2FeaturesEXT extended_dynamic_state2_features;
VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT vertex_input_dynamic_state_features;
VkPhysicalDeviceInheritedViewportScissorFeaturesNV inherited_viewport_scissor_features;
VkPhysicalDeviceProvokingVertexFeaturesEXT provoking_vertex_features;
VkPhysicalDeviceMultiDrawFeaturesEXT multi_draw_features;
// If a new feature is added here that involves a SPIR-V capability add also in spirv_validation_generator.py
// This is known by checking the table in the spec or if the struct is in a <spirvcapability> in vk.xml
};
class QUEUE_FAMILY_PERF_COUNTERS {
public:
std::vector<VkPerformanceCounterKHR> counters;
};
class PHYSICAL_DEVICE_STATE {
public:
safe_VkPhysicalDeviceFeatures2 features2 = {};
VkPhysicalDevice phys_device = VK_NULL_HANDLE;
uint32_t queue_family_known_count = 1; // spec implies one QF must always be supported
std::vector<VkQueueFamilyProperties> queue_family_properties;
VkSurfaceCapabilitiesKHR surfaceCapabilities = {};
std::vector<VkPresentModeKHR> present_modes;
std::vector<VkSurfaceFormatKHR> surface_formats;
uint32_t display_plane_property_count = 0;
// Map of queue family index to QUEUE_FAMILY_PERF_COUNTERS
layer_data::unordered_map<uint32_t, std::unique_ptr<QUEUE_FAMILY_PERF_COUNTERS>> perf_counters;
// TODO These are currently used by CoreChecks, but should probably be refactored
bool vkGetPhysicalDeviceSurfaceCapabilitiesKHR_called = false;
bool vkGetPhysicalDeviceDisplayPlanePropertiesKHR_called = false;
};
struct GpuQueue {
VkPhysicalDevice gpu;
uint32_t queue_family_index;
};
inline bool operator==(GpuQueue const& lhs, GpuQueue const& rhs) {
return (lhs.gpu == rhs.gpu && lhs.queue_family_index == rhs.queue_family_index);
}
namespace std {
template <>
struct hash<GpuQueue> {
size_t operator()(GpuQueue gq) const throw() {
return hash<uint64_t>()((uint64_t)(gq.gpu)) ^ hash<uint32_t>()(gq.queue_family_index);
}
};
} // namespace std
class SWAPCHAIN_NODE;
class SURFACE_STATE : public BASE_NODE {
public:
SWAPCHAIN_NODE* swapchain = nullptr;
layer_data::unordered_map<GpuQueue, bool> gpu_queue_support;
SURFACE_STATE(VkSurfaceKHR s) : BASE_NODE(s, kVulkanObjectTypeSurfaceKHR) {}
VkSurfaceKHR surface() const { return handle_.Cast<VkSurfaceKHR>(); }
};
class DISPLAY_MODE_STATE : public BASE_NODE {
public:
VkPhysicalDevice physical_device;
DISPLAY_MODE_STATE(VkDisplayModeKHR dm, VkPhysicalDevice phys_dev)
: BASE_NODE(dm, kVulkanObjectTypeDisplayModeKHR), physical_device(phys_dev) {}
VkDisplayModeKHR display_mode() const { return handle_.Cast<VkDisplayModeKHR>(); }
};