Skip to content

Commit c66108b

Browse files
author
ssjia
committed
[ET-VK][testing] Add ETVK_FORCE_NO_EXTENSIONS debug flag
Add a build config flag `etvk.force_no_extensions` that causes all Vulkan extension support queries in Adapter.h to return false. This makes it easy to test fallback code paths for devices that lack optional extensions (e.g. 8-bit storage buffers, float16, dot product) on a development host that would otherwise report support for them. Enable with: --config etvk.force_no_extensions=1 Differential Revision: [D94314257](https://our.internmc.facebook.com/intern/diff/D94314257/) [ghstack-poisoned]
1 parent 616c756 commit c66108b

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

backends/vulkan/runtime/vk_api/Adapter.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ class Adapter final {
179179
// Physical Device Features
180180

181181
inline bool supports_16bit_storage_buffers() {
182+
#ifdef ETVK_FORCE_NO_EXTENSIONS
183+
return false;
184+
#endif
182185
#ifdef VK_KHR_16bit_storage
183186
return physical_device_.shader_16bit_storage.storageBuffer16BitAccess ==
184187
VK_TRUE;
@@ -188,6 +191,9 @@ class Adapter final {
188191
}
189192

190193
inline bool supports_8bit_storage_buffers() {
194+
#ifdef ETVK_FORCE_NO_EXTENSIONS
195+
return false;
196+
#endif
191197
#ifdef VK_KHR_8bit_storage
192198
return physical_device_.shader_8bit_storage.storageBuffer8BitAccess ==
193199
VK_TRUE;
@@ -197,6 +203,9 @@ class Adapter final {
197203
}
198204

199205
inline bool supports_float16_shader_types() {
206+
#ifdef ETVK_FORCE_NO_EXTENSIONS
207+
return false;
208+
#endif
200209
#ifdef VK_KHR_shader_float16_int8
201210
return physical_device_.shader_float16_int8_types.shaderFloat16 == VK_TRUE;
202211
#else
@@ -205,6 +214,9 @@ class Adapter final {
205214
}
206215

207216
inline bool supports_int8_shader_types() {
217+
#ifdef ETVK_FORCE_NO_EXTENSIONS
218+
return false;
219+
#endif
208220
#ifdef VK_KHR_shader_float16_int8
209221
return physical_device_.shader_float16_int8_types.shaderInt8 == VK_TRUE;
210222
#else
@@ -213,6 +225,9 @@ class Adapter final {
213225
}
214226

215227
inline bool supports_int8_dot_product() {
228+
#ifdef ETVK_FORCE_NO_EXTENSIONS
229+
return false;
230+
#endif
216231
#ifdef VK_KHR_shader_integer_dot_product
217232
return physical_device_.shader_int_dot_product_features
218233
.shaderIntegerDotProduct == VK_TRUE;
@@ -222,6 +237,9 @@ class Adapter final {
222237
}
223238

224239
inline bool supports_nv_cooperative_matrix2() {
240+
#ifdef ETVK_FORCE_NO_EXTENSIONS
241+
return false;
242+
#endif
225243
#ifdef VK_NV_cooperative_matrix2
226244
return physical_device_.cooperative_matrix2_features
227245
.cooperativeMatrixWorkgroupScope == VK_TRUE &&
@@ -235,14 +253,23 @@ class Adapter final {
235253
}
236254

237255
inline bool supports_int16_shader_types() {
256+
#ifdef ETVK_FORCE_NO_EXTENSIONS
257+
return false;
258+
#endif
238259
return physical_device_.supports_int16_shader_types;
239260
}
240261

241262
inline bool supports_int64_shader_types() {
263+
#ifdef ETVK_FORCE_NO_EXTENSIONS
264+
return false;
265+
#endif
242266
return physical_device_.supports_int64_shader_types;
243267
}
244268

245269
inline bool supports_float64_shader_types() {
270+
#ifdef ETVK_FORCE_NO_EXTENSIONS
271+
return false;
272+
#endif
246273
return physical_device_.supports_float64_shader_types;
247274
}
248275

backends/vulkan/targets.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def get_vulkan_preprocessor_flags(no_volk, is_fbcode):
2020
android_flags = []
2121

2222
debug_mode = read_config("etvk", "debug", "0") == "1"
23+
force_no_extensions = read_config("etvk", "force_no_extensions", "0") == "1"
2324

2425
if not no_volk:
2526
for flags in [default_flags, android_flags]:
@@ -68,6 +69,9 @@ def get_vulkan_preprocessor_flags(no_volk, is_fbcode):
6869
if debug_mode:
6970
VK_API_PREPROCESSOR_FLAGS += ["-DVULKAN_DEBUG"]
7071

72+
if force_no_extensions:
73+
VK_API_PREPROCESSOR_FLAGS += ["-DETVK_FORCE_NO_EXTENSIONS"]
74+
7175
return VK_API_PREPROCESSOR_FLAGS
7276

7377
def get_labels(no_volk):

0 commit comments

Comments
 (0)