Skip to content

Commit ca44965

Browse files
authored
Introduce no_volk buck targets
Differential Revision: D65827152 Pull Request resolved: #6910
1 parent ae61100 commit ca44965

File tree

6 files changed

+292
-118
lines changed

6 files changed

+292
-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;
@@ -272,6 +278,7 @@ std::string Adapter::stringize() const {
272278
PRINT_PROP_VEC3(limits, maxComputeWorkGroupSize);
273279
ss << " }" << std::endl;
274280

281+
#ifdef VK_KHR_16bit_storage
275282
ss << " 16bit Storage Features {" << std::endl;
276283
PRINT_PROP(physical_device_.shader_16bit_storage, storageBuffer16BitAccess);
277284
PRINT_PROP(
@@ -280,18 +287,23 @@ std::string Adapter::stringize() const {
280287
PRINT_PROP(physical_device_.shader_16bit_storage, storagePushConstant16);
281288
PRINT_PROP(physical_device_.shader_16bit_storage, storageInputOutput16);
282289
ss << " }" << std::endl;
290+
#endif /* VK_KHR_16bit_storage */
283291

292+
#ifdef VK_KHR_8bit_storage
284293
ss << " 8bit Storage Features {" << std::endl;
285294
PRINT_PROP(physical_device_.shader_8bit_storage, storageBuffer8BitAccess);
286295
PRINT_PROP(
287296
physical_device_.shader_8bit_storage, uniformAndStorageBuffer8BitAccess);
288297
PRINT_PROP(physical_device_.shader_8bit_storage, storagePushConstant8);
289298
ss << " }" << std::endl;
299+
#endif /* VK_KHR_8bit_storage */
290300

301+
#ifdef VK_KHR_shader_float16_int8
291302
ss << " Shader 16bit and 8bit Features {" << std::endl;
292303
PRINT_PROP(physical_device_.shader_float16_int8_types, shaderFloat16);
293304
PRINT_PROP(physical_device_.shader_float16_int8_types, shaderInt8);
294305
ss << " }" << std::endl;
306+
#endif /* VK_KHR_shader_float16_int8 */
295307

296308
const VkPhysicalDeviceMemoryProperties& mem_props =
297309
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
@@ -162,21 +162,37 @@ class Adapter final {
162162
// Physical Device Features
163163

164164
inline bool supports_16bit_storage_buffers() {
165+
#ifdef VK_KHR_16bit_storage
165166
return physical_device_.shader_16bit_storage.storageBuffer16BitAccess ==
166167
VK_TRUE;
168+
#else
169+
return false;
170+
#endif /* VK_KHR_16bit_storage */
167171
}
168172

169173
inline bool supports_8bit_storage_buffers() {
174+
#ifdef VK_KHR_8bit_storage
170175
return physical_device_.shader_8bit_storage.storageBuffer8BitAccess ==
171176
VK_TRUE;
177+
#else
178+
return false;
179+
#endif /* VK_KHR_8bit_storage */
172180
}
173181

174182
inline bool supports_float16_shader_types() {
183+
#ifdef VK_KHR_shader_float16_int8
175184
return physical_device_.shader_float16_int8_types.shaderFloat16 == VK_TRUE;
185+
#else
186+
return false;
187+
#endif /* VK_KHR_shader_float16_int8 */
176188
}
177189

178190
inline bool supports_int8_shader_types() {
191+
#ifdef VK_KHR_shader_float16_int8
179192
return physical_device_.shader_float16_int8_types.shaderInt8 == VK_TRUE;
193+
#else
194+
return false;
195+
#endif /* VK_KHR_shader_float16_int8 */
180196
}
181197

182198
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)