Skip to content

Commit e76103f

Browse files
SS-JIAfacebook-github-bot
authored andcommitted
Introduce no_volk buck targets
Summary: TSIA. Introduce variants of the vulkan backend buck targets that do not use volk. Differential Revision: D65827152
1 parent 5663e3c commit e76103f

File tree

6 files changed

+289
-118
lines changed

6 files changed

+289
-118
lines changed

backends/vulkan/runtime/vk_api/Adapter.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,15 @@ VkDevice create_logical_device(
7373
#ifdef VK_ANDROID_external_memory_android_hardware_buffer
7474
VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME,
7575
#endif /* VK_ANDROID_external_memory_android_hardware_buffer */
76+
#ifdef VK_KHR_16bit_storage
7677
VK_KHR_16BIT_STORAGE_EXTENSION_NAME,
78+
#endif /* VK_KHR_16bit_storage */
79+
#ifdef VK_KHR_8bit_storage
7780
VK_KHR_8BIT_STORAGE_EXTENSION_NAME,
81+
#endif /* VK_KHR_8bit_storage */
82+
#ifdef VK_KHR_shader_float16_int8
7883
VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME,
84+
#endif /* VK_KHR_shader_float16_int8 */
7985
};
8086

8187
std::vector<const char*> enabled_device_extensions;
@@ -240,6 +246,7 @@ std::string Adapter::stringize() const {
240246
PRINT_PROP_VEC3(limits, maxComputeWorkGroupSize);
241247
ss << " }" << std::endl;
242248

249+
#ifdef VK_KHR_16bit_storage
243250
ss << " 16bit Storage Features {" << std::endl;
244251
PRINT_PROP(physical_device_.shader_16bit_storage, storageBuffer16BitAccess);
245252
PRINT_PROP(
@@ -248,18 +255,23 @@ std::string Adapter::stringize() const {
248255
PRINT_PROP(physical_device_.shader_16bit_storage, storagePushConstant16);
249256
PRINT_PROP(physical_device_.shader_16bit_storage, storageInputOutput16);
250257
ss << " }" << std::endl;
258+
#endif /* VK_KHR_16bit_storage */
251259

260+
#ifdef VK_KHR_8bit_storage
252261
ss << " 8bit Storage Features {" << std::endl;
253262
PRINT_PROP(physical_device_.shader_8bit_storage, storageBuffer8BitAccess);
254263
PRINT_PROP(
255264
physical_device_.shader_8bit_storage, uniformAndStorageBuffer8BitAccess);
256265
PRINT_PROP(physical_device_.shader_8bit_storage, storagePushConstant8);
257266
ss << " }" << std::endl;
267+
#endif /* VK_KHR_8bit_storage */
258268

269+
#ifdef VK_KHR_shader_float16_int8
259270
ss << " Shader 16bit and 8bit Features {" << std::endl;
260271
PRINT_PROP(physical_device_.shader_float16_int8_types, shaderFloat16);
261272
PRINT_PROP(physical_device_.shader_float16_int8_types, shaderInt8);
262273
ss << " }" << std::endl;
274+
#endif /* VK_KHR_shader_float16_int8 */
263275

264276
const VkPhysicalDeviceMemoryProperties& mem_props =
265277
physical_device_.memory_properties;

backends/vulkan/runtime/vk_api/Adapter.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,37 @@ class Adapter final {
156156
// Physical Device Features
157157

158158
inline bool supports_16bit_storage_buffers() {
159+
#ifdef VK_KHR_16bit_storage
159160
return physical_device_.shader_16bit_storage.storageBuffer16BitAccess ==
160161
VK_TRUE;
162+
#else
163+
return false;
164+
#endif /* VK_KHR_16bit_storage */
161165
}
162166

163167
inline bool supports_8bit_storage_buffers() {
168+
#ifdef VK_KHR_8bit_storage
164169
return physical_device_.shader_8bit_storage.storageBuffer8BitAccess ==
165170
VK_TRUE;
171+
#else
172+
return false;
173+
#endif /* VK_KHR_8bit_storage */
166174
}
167175

168176
inline bool supports_float16_shader_types() {
177+
#ifdef VK_KHR_shader_float16_int8
169178
return physical_device_.shader_float16_int8_types.shaderFloat16 == VK_TRUE;
179+
#else
180+
return false;
181+
#endif /* VK_KHR_shader_float16_int8 */
170182
}
171183

172184
inline bool supports_int8_shader_types() {
185+
#ifdef VK_KHR_shader_float16_int8
173186
return physical_device_.shader_float16_int8_types.shaderInt8 == VK_TRUE;
187+
#else
188+
return false;
189+
#endif /* VK_KHR_shader_float16_int8 */
174190
}
175191

176192
inline bool supports_int16_shader_types() {

backends/vulkan/runtime/vk_api/Device.cpp

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,27 @@ PhysicalDevice::PhysicalDevice(VkPhysicalDevice physical_device_handle)
2222
: handle(physical_device_handle),
2323
properties{},
2424
memory_properties{},
25+
#ifdef VK_KHR_16bit_storage
26+
extension_features(&shader_16bit_storage),
2527
shader_16bit_storage{
2628
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES},
29+
#else
30+
extension_features{nullptr},
31+
#endif /* VK_KHR_16bit_storage */
32+
#ifdef VK_KHR_8bit_storage
2733
shader_8bit_storage{
2834
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES},
35+
#endif /* VK_KHR_8bit_storage */
36+
#ifdef VK_KHR_shader_float16_int8
2937
shader_float16_int8_types{
3038
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES_KHR},
39+
#endif /* VK_KHR_shader_float16_int8 */
3140
queue_families{},
3241
num_compute_queues(0),
3342
supports_int16_shader_types(false),
3443
has_unified_memory(false),
3544
has_timestamps(properties.limits.timestampComputeAndGraphics),
36-
timestamp_period(properties.limits.timestampPeriod),
37-
extension_features(&shader_16bit_storage) {
45+
timestamp_period(properties.limits.timestampPeriod) {
3846
// Extract physical device properties
3947
vkGetPhysicalDeviceProperties(handle, &properties);
4048
vkGetPhysicalDeviceMemoryProperties(handle, &memory_properties);
@@ -43,10 +51,32 @@ PhysicalDevice::PhysicalDevice(VkPhysicalDevice physical_device_handle)
4351
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2};
4452

4553
// Create linked list to query availability of extensions
54+
55+
#ifdef VK_KHR_16bit_storage
4656
features2.pNext = &shader_16bit_storage;
57+
#elif defined(VK_KHR_8bit_storage)
58+
features2.pNext = &shader_8bit_storage;
59+
#elif defined(VK_KHR_shader_float16_int8)
60+
features2.pNext = &shader_float16_int8_types;
61+
#endif /* VK_KHR_16bit_storage */
62+
63+
#if defined(VK_KHR_16bit_storage) && defined(VK_KHR_8bit_storage)
4764
shader_16bit_storage.pNext = &shader_8bit_storage;
65+
#elif defined(VK_KHR_16bit_storage) && defined(VK_KHR_shader_float16_int8)
66+
shader_16bit_storage.pNext = &shader_float16_int8_types;
67+
#elif defined(VK_KHR_16bit_storage)
68+
shader_16bit_storage.pNext = nullptr;
69+
#endif
70+
71+
#if defined(VK_KHR_8bit_storage) && defined(VK_KHR_shader_float16_int8)
4872
shader_8bit_storage.pNext = &shader_float16_int8_types;
73+
#elif defined(VK_KHR_8bit_storage)
74+
shader_8bit_storage.pNext = nullptr;
75+
#endif
76+
77+
#ifdef VK_KHR_shader_float16_int8
4978
shader_float16_int8_types.pNext = nullptr;
79+
#endif
5080

5181
vkGetPhysicalDeviceFeatures2(handle, &features2);
5282

backends/vulkan/runtime/vk_api/Device.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,20 @@ struct PhysicalDevice final {
2525
// Properties obtained from Vulkan
2626
VkPhysicalDeviceProperties properties;
2727
VkPhysicalDeviceMemoryProperties memory_properties;
28+
29+
// Head of the linked list of extensions to be requested
30+
void* extension_features;
31+
2832
// Additional features available from extensions
33+
#ifdef VK_KHR_16bit_storage
2934
VkPhysicalDevice16BitStorageFeatures shader_16bit_storage;
35+
#endif /* VK_KHR_16bit_storage */
36+
#ifdef VK_KHR_8bit_storage
3037
VkPhysicalDevice8BitStorageFeatures shader_8bit_storage;
38+
#endif /* VK_KHR_8bit_storage */
39+
#ifdef VK_KHR_shader_float16_int8
3140
VkPhysicalDeviceShaderFloat16Int8Features shader_float16_int8_types;
41+
#endif /* VK_KHR_shader_float16_int8 */
3242

3343
// Available GPU queues
3444
std::vector<VkQueueFamilyProperties> queue_families;
@@ -40,9 +50,6 @@ struct PhysicalDevice final {
4050
bool has_timestamps;
4151
float timestamp_period;
4252

43-
// Head of the linked list of extensions to be requested
44-
void* extension_features{nullptr};
45-
4653
explicit PhysicalDevice(VkPhysicalDevice);
4754
};
4855

0 commit comments

Comments
 (0)