Skip to content

Commit 8b32900

Browse files
committed
Allow layers to expose new extensions
1 parent bb91123 commit 8b32900

File tree

11 files changed

+208
-22
lines changed

11 files changed

+208
-22
lines changed

generator/vk_layer/source/instance.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,19 @@ static std::unordered_map<void*, std::unique_ptr<Instance>> g_instances;
3838
const APIVersion Instance::minAPIVersion { 1, 1 };
3939

4040
/* See header for documentation. */
41-
const std::vector<std::string> Instance::extraExtensions {
41+
const std::vector<std::string> Instance::requiredDriverExtensions {
4242
VK_EXT_DEBUG_UTILS_EXTENSION_NAME
4343
};
4444

45+
/* See header for documentation. */
46+
const std::vector<std::pair<std::string, uint32_t>> Instance::injectedInstanceExtensions {};
47+
48+
/* See header for documentation. */
49+
const std::vector<std::pair<std::string, uint32_t>> Instance::injectedDeviceExtensions {};
50+
51+
/* See header for documentation. */
52+
const std::vector<std::string> Instance::injectedAPIFunctions {};
53+
4554
/* See header for documentation. */
4655
void Instance::store(
4756
VkInstance handle,

generator/vk_layer/source/instance.hpp

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,34 @@ class Instance
143143
static const APIVersion minAPIVersion;
144144

145145
/**
146-
* @brief The minimum set of instance extensions needed by this layer.
146+
* @brief Required extensions from the driver.
147+
*
148+
* The layer will attempt to enable these even if the application does not.
149+
*/
150+
static const std::vector<std::string> requiredDriverExtensions;
151+
152+
/**
153+
* @brief Additional instance extensions injected by the layer.
154+
*
155+
* The layer will expose these even if the driver does not.
156+
*/
157+
static const std::vector<std::pair<std::string, uint32_t>> injectedInstanceExtensions;
158+
159+
/**
160+
* @brief Additional device extensions injected by the layer.
161+
*
162+
* The layer will expose these even if the driver does not.
163+
*/
164+
static const std::vector<std::pair<std::string, uint32_t>> injectedDeviceExtensions;
165+
166+
/**
167+
* @brief Additional API functions that are injected by the layer.
168+
*
169+
* This list must include both instance and device functions, because
170+
* vkGetInstanceProcAddr can (inefficiently) be used to return device
171+
* functions.
172+
*
173+
* The layer will expose these even if the driver does not.
147174
*/
148-
static const std::vector<std::string> extraExtensions;
175+
static const std::vector<std::string> injectedAPIFunctions;
149176
};

layer_example/source/instance.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,21 @@
3535
static std::unordered_map<void*, std::unique_ptr<Instance>> g_instances;
3636

3737
/* See header for documentation. */
38-
const APIVersion Instance::minAPIVersion {1, 1};
38+
const APIVersion Instance::minAPIVersion { 1, 1 };
3939

4040
/* See header for documentation. */
41-
const std::vector<std::string> Instance::extraExtensions {VK_EXT_DEBUG_UTILS_EXTENSION_NAME};
41+
const std::vector<std::string> Instance::requiredDriverExtensions {
42+
VK_EXT_DEBUG_UTILS_EXTENSION_NAME
43+
};
44+
45+
/* See header for documentation. */
46+
const std::vector<std::pair<std::string, uint32_t>> Instance::injectedInstanceExtensions {};
47+
48+
/* See header for documentation. */
49+
const std::vector<std::pair<std::string, uint32_t>> Instance::injectedDeviceExtensions {};
50+
51+
/* See header for documentation. */
52+
const std::vector<std::string> Instance::injectedAPIFunctions {};
4253

4354
/* See header for documentation. */
4455
void Instance::store(VkInstance handle, std::unique_ptr<Instance>& instance)

layer_example/source/instance.hpp

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,34 @@ class Instance
137137
static const APIVersion minAPIVersion;
138138

139139
/**
140-
* @brief The minimum set of instance extensions needed by this layer.
140+
* @brief Required extensions from the driver.
141+
*
142+
* The layer will attempt to enable these even if the application does not.
143+
*/
144+
static const std::vector<std::string> requiredDriverExtensions;
145+
146+
/**
147+
* @brief Additional instance extensions injected by the layer.
148+
*
149+
* The layer will expose these even if the driver does not.
150+
*/
151+
static const std::vector<std::pair<std::string, uint32_t>> injectedInstanceExtensions;
152+
153+
/**
154+
* @brief Additional device extensions injected by the layer.
155+
*
156+
* The layer will expose these even if the driver does not.
157+
*/
158+
static const std::vector<std::pair<std::string, uint32_t>> injectedDeviceExtensions;
159+
160+
/**
161+
* @brief Additional API functions that are injected by the layer.
162+
*
163+
* This list must include both instance and device functions, because
164+
* vkGetInstanceProcAddr can (inefficiently) be used to return device
165+
* functions.
166+
*
167+
* The layer will expose these even if the driver does not.
141168
*/
142-
static const std::vector<std::string> extraExtensions;
169+
static const std::vector<std::string> injectedAPIFunctions;
143170
};

layer_gpu_profile/source/instance.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,22 @@
3535
static std::unordered_map<void*, std::unique_ptr<Instance>> g_instances;
3636

3737
/* See header for documentation. */
38-
const APIVersion Instance::minAPIVersion {1, 1};
38+
const APIVersion Instance::minAPIVersion { 1, 1 };
3939

4040
/* See header for documentation. */
41-
const std::vector<std::string> Instance::extraExtensions {
41+
const std::vector<std::string> Instance::requiredDriverExtensions {
4242
VK_EXT_DEBUG_UTILS_EXTENSION_NAME,
4343
};
4444

45+
/* See header for documentation. */
46+
const std::vector<std::pair<std::string, uint32_t>> Instance::injectedInstanceExtensions {};
47+
48+
/* See header for documentation. */
49+
const std::vector<std::pair<std::string, uint32_t>> Instance::injectedDeviceExtensions {};
50+
51+
/* See header for documentation. */
52+
const std::vector<std::string> Instance::injectedAPIFunctions {};
53+
4554
/* See header for documentation. */
4655
void Instance::store(VkInstance handle, std::unique_ptr<Instance>& instance)
4756
{

layer_gpu_profile/source/instance.hpp

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,34 @@ class Instance
143143
static const APIVersion minAPIVersion;
144144

145145
/**
146-
* @brief The minimum set of instance extensions needed by this layer.
146+
* @brief Required extensions from the driver.
147+
*
148+
* The layer will attempt to enable these even if the application does not.
149+
*/
150+
static const std::vector<std::string> requiredDriverExtensions;
151+
152+
/**
153+
* @brief Additional instance extensions injected by the layer.
154+
*
155+
* The layer will expose these even if the driver does not.
156+
*/
157+
static const std::vector<std::pair<std::string, uint32_t>> injectedInstanceExtensions;
158+
159+
/**
160+
* @brief Additional device extensions injected by the layer.
161+
*
162+
* The layer will expose these even if the driver does not.
163+
*/
164+
static const std::vector<std::pair<std::string, uint32_t>> injectedDeviceExtensions;
165+
166+
/**
167+
* @brief Additional API functions that are injected by the layer.
168+
*
169+
* This list must include both instance and device functions, because
170+
* vkGetInstanceProcAddr can (inefficiently) be used to return device
171+
* functions.
172+
*
173+
* The layer will expose these even if the driver does not.
147174
*/
148-
static const std::vector<std::string> extraExtensions;
175+
static const std::vector<std::string> injectedAPIFunctions;
149176
};

layer_gpu_support/source/instance.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,22 @@
3535
static std::unordered_map<void*, std::unique_ptr<Instance>> g_instances;
3636

3737
/* See header for documentation. */
38-
const APIVersion Instance::minAPIVersion {1, 1};
38+
const APIVersion Instance::minAPIVersion { 1, 1 };
3939

4040
/* See header for documentation. */
41-
const std::vector<std::string> Instance::extraExtensions {
41+
const std::vector<std::string> Instance::requiredDriverExtensions {
4242
VK_EXT_DEBUG_UTILS_EXTENSION_NAME,
4343
};
4444

45+
/* See header for documentation. */
46+
const std::vector<std::pair<std::string, uint32_t>> Instance::injectedInstanceExtensions {};
47+
48+
/* See header for documentation. */
49+
const std::vector<std::pair<std::string, uint32_t>> Instance::injectedDeviceExtensions {};
50+
51+
/* See header for documentation. */
52+
const std::vector<std::string> Instance::injectedAPIFunctions {};
53+
4554
/* See header for documentation. */
4655
void Instance::store(VkInstance handle, std::unique_ptr<Instance>& instance)
4756
{

layer_gpu_support/source/instance.hpp

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,34 @@ class Instance
142142
static const APIVersion minAPIVersion;
143143

144144
/**
145-
* @brief The minimum set of instance extensions needed by this layer.
145+
* @brief Required extensions from the driver.
146+
*
147+
* The layer will attempt to enable these even if the application does not.
148+
*/
149+
static const std::vector<std::string> requiredDriverExtensions;
150+
151+
/**
152+
* @brief Additional instance extensions injected by the layer.
153+
*
154+
* The layer will expose these even if the driver does not.
155+
*/
156+
static const std::vector<std::pair<std::string, uint32_t>> injectedInstanceExtensions;
157+
158+
/**
159+
* @brief Additional device extensions injected by the layer.
160+
*
161+
* The layer will expose these even if the driver does not.
162+
*/
163+
static const std::vector<std::pair<std::string, uint32_t>> injectedDeviceExtensions;
164+
165+
/**
166+
* @brief Additional API functions that are injected by the layer.
167+
*
168+
* This list must include both instance and device functions, because
169+
* vkGetInstanceProcAddr can (inefficiently) be used to return device
170+
* functions.
171+
*
172+
* The layer will expose these even if the driver does not.
146173
*/
147-
static const std::vector<std::string> extraExtensions;
174+
static const std::vector<std::string> injectedAPIFunctions;
148175
};

layer_gpu_timeline/source/instance.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,22 @@
3535
static std::unordered_map<void*, std::unique_ptr<Instance>> g_instances;
3636

3737
/* See header for documentation. */
38-
const APIVersion Instance::minAPIVersion {1, 1};
38+
const APIVersion Instance::minAPIVersion { 1, 1 };
3939

4040
/* See header for documentation. */
41-
const std::vector<std::string> Instance::extraExtensions {
41+
const std::vector<std::string> Instance::requiredDriverExtensions {
4242
VK_EXT_DEBUG_UTILS_EXTENSION_NAME,
4343
};
4444

45+
/* See header for documentation. */
46+
const std::vector<std::pair<std::string, uint32_t>> Instance::injectedInstanceExtensions {};
47+
48+
/* See header for documentation. */
49+
const std::vector<std::pair<std::string, uint32_t>> Instance::injectedDeviceExtensions {};
50+
51+
/* See header for documentation. */
52+
const std::vector<std::string> Instance::injectedAPIFunctions {};
53+
4554
/* See header for documentation. */
4655
void Instance::store(VkInstance handle, std::unique_ptr<Instance>& instance)
4756
{

layer_gpu_timeline/source/instance.hpp

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,34 @@ class Instance
137137
static const APIVersion minAPIVersion;
138138

139139
/**
140-
* @brief The minimum set of instance extensions needed by this layer.
140+
* @brief Required extensions from the driver.
141+
*
142+
* The layer will attempt to enable these even if the application does not.
143+
*/
144+
static const std::vector<std::string> requiredDriverExtensions;
145+
146+
/**
147+
* @brief Additional instance extensions injected by the layer.
148+
*
149+
* The layer will expose these even if the driver does not.
150+
*/
151+
static const std::vector<std::pair<std::string, uint32_t>> injectedInstanceExtensions;
152+
153+
/**
154+
* @brief Additional device extensions injected by the layer.
155+
*
156+
* The layer will expose these even if the driver does not.
157+
*/
158+
static const std::vector<std::pair<std::string, uint32_t>> injectedDeviceExtensions;
159+
160+
/**
161+
* @brief Additional API functions that are injected by the layer.
162+
*
163+
* This list must include both instance and device functions, because
164+
* vkGetInstanceProcAddr can (inefficiently) be used to return device
165+
* functions.
166+
*
167+
* The layer will expose these even if the driver does not.
141168
*/
142-
static const std::vector<std::string> extraExtensions;
169+
static const std::vector<std::string> injectedAPIFunctions;
143170
};

0 commit comments

Comments
 (0)