Skip to content

Commit 50f35d3

Browse files
committed
Enable some important shader extensions on < 1.3 core devices.
1 parent 4fcf8e7 commit 50f35d3

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

vulkan/context.cpp

+64
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,30 @@ bool Context::create_device(VkPhysicalDevice gpu_, VkSurfaceKHR surface,
12841284
{
12851285
if (has_extension(VK_EXT_HOST_QUERY_RESET_EXTENSION_NAME))
12861286
ADD_CHAIN(ext.host_query_reset_features, HOST_QUERY_RESET_FEATURES);
1287+
1288+
if (has_extension(VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME))
1289+
{
1290+
ADD_CHAIN(ext.float16_int8_features, FLOAT16_INT8_FEATURES_KHR);
1291+
enabled_extensions.push_back(VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME);
1292+
}
1293+
1294+
if (has_extension(VK_KHR_16BIT_STORAGE_EXTENSION_NAME))
1295+
{
1296+
ADD_CHAIN(ext.storage_16bit_features, 16BIT_STORAGE_FEATURES_KHR);
1297+
enabled_extensions.push_back(VK_KHR_16BIT_STORAGE_EXTENSION_NAME);
1298+
}
1299+
1300+
if (has_extension(VK_KHR_8BIT_STORAGE_EXTENSION_NAME))
1301+
{
1302+
ADD_CHAIN(ext.storage_8bit_features, 8BIT_STORAGE_FEATURES_KHR);
1303+
enabled_extensions.push_back(VK_KHR_8BIT_STORAGE_EXTENSION_NAME);
1304+
}
1305+
1306+
if (has_extension(VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME))
1307+
{
1308+
ADD_CHAIN(ext.subgroup_size_control_features, SUBGROUP_SIZE_CONTROL_FEATURES_EXT);
1309+
enabled_extensions.push_back(VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME);
1310+
}
12871311
}
12881312

12891313
if (ext.device_api_core_version >= VK_API_VERSION_1_3)
@@ -1428,9 +1452,37 @@ bool Context::create_device(VkPhysicalDevice gpu_, VkSurfaceKHR surface,
14281452
vkGetPhysicalDeviceFeatures2(gpu, &pdf2);
14291453
}
14301454

1455+
// Promote fallback features to core structs.
14311456
if (ext.host_query_reset_features.hostQueryReset)
14321457
ext.vk12_features.hostQueryReset = VK_TRUE;
14331458

1459+
if (ext.storage_16bit_features.storageBuffer16BitAccess)
1460+
ext.vk11_features.storageBuffer16BitAccess = VK_TRUE;
1461+
if (ext.storage_16bit_features.storageInputOutput16)
1462+
ext.vk11_features.storageInputOutput16 = VK_TRUE;
1463+
if (ext.storage_16bit_features.storagePushConstant16)
1464+
ext.vk11_features.storagePushConstant16 = VK_TRUE;
1465+
if (ext.storage_16bit_features.uniformAndStorageBuffer16BitAccess)
1466+
ext.vk11_features.uniformAndStorageBuffer16BitAccess = VK_TRUE;
1467+
1468+
if (ext.storage_8bit_features.storageBuffer8BitAccess)
1469+
ext.vk12_features.storageBuffer8BitAccess = VK_TRUE;
1470+
if (ext.storage_8bit_features.storagePushConstant8)
1471+
ext.vk12_features.storagePushConstant8 = VK_TRUE;
1472+
if (ext.storage_8bit_features.uniformAndStorageBuffer8BitAccess)
1473+
ext.vk12_features.uniformAndStorageBuffer8BitAccess = VK_TRUE;
1474+
1475+
if (ext.float16_int8_features.shaderFloat16)
1476+
ext.vk12_features.shaderFloat16 = VK_TRUE;
1477+
if (ext.float16_int8_features.shaderInt8)
1478+
ext.vk12_features.shaderInt8 = VK_TRUE;
1479+
1480+
if (ext.subgroup_size_control_features.computeFullSubgroups)
1481+
ext.vk13_features.computeFullSubgroups = VK_TRUE;
1482+
if (ext.subgroup_size_control_features.subgroupSizeControl)
1483+
ext.vk13_features.subgroupSizeControl = VK_TRUE;
1484+
///
1485+
14341486
ext.vk11_features.multiviewGeometryShader = VK_FALSE;
14351487
ext.vk11_features.multiviewTessellationShader = VK_FALSE;
14361488
ext.vk11_features.protectedMemory = VK_FALSE;
@@ -1447,6 +1499,7 @@ bool Context::create_device(VkPhysicalDevice gpu_, VkSurfaceKHR surface,
14471499

14481500
ext.mesh_shader_features.primitiveFragmentShadingRateMeshShader = VK_FALSE;
14491501
ext.mesh_shader_features.meshShaderQueries = VK_FALSE;
1502+
ext.mesh_shader_features.multiviewMeshShader = VK_FALSE;
14501503

14511504
ext.device_generated_commands_compute_features.deviceGeneratedComputeCaptureReplay = VK_FALSE;
14521505
// TODO
@@ -1516,6 +1569,7 @@ bool Context::create_device(VkPhysicalDevice gpu_, VkSurfaceKHR surface,
15161569
VkPhysicalDeviceDriverProperties driver_properties = {};
15171570
VkPhysicalDeviceIDProperties id_properties = {};
15181571
VkPhysicalDeviceSubgroupProperties subgroup_properties = {};
1572+
VkPhysicalDeviceSubgroupSizeControlProperties size_control_props = {};
15191573
ppNext = &props.pNext;
15201574

15211575
if (ext.device_api_core_version >= VK_API_VERSION_1_2)
@@ -1527,6 +1581,8 @@ bool Context::create_device(VkPhysicalDevice gpu_, VkSurfaceKHR surface,
15271581
{
15281582
if (has_extension(VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME))
15291583
ADD_CHAIN(driver_properties, DRIVER_PROPERTIES);
1584+
if (has_extension(VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME))
1585+
ADD_CHAIN(size_control_props, SUBGROUP_SIZE_CONTROL_PROPERTIES);
15301586
ADD_CHAIN(id_properties, ID_PROPERTIES);
15311587
ADD_CHAIN(subgroup_properties, SUBGROUP_PROPERTIES);
15321588
}
@@ -1565,6 +1621,14 @@ bool Context::create_device(VkPhysicalDevice gpu_, VkSurfaceKHR surface,
15651621
else
15661622
ext.driver_id = ext.vk12_props.driverID;
15671623

1624+
if (ext.device_api_core_version < VK_API_VERSION_1_3)
1625+
{
1626+
ext.vk13_props.minSubgroupSize = size_control_props.minSubgroupSize;
1627+
ext.vk13_props.maxSubgroupSize = size_control_props.maxSubgroupSize;
1628+
ext.vk13_props.requiredSubgroupSizeStages = size_control_props.requiredSubgroupSizeStages;
1629+
ext.vk13_props.maxComputeWorkgroupSubgroups = size_control_props.maxComputeWorkgroupSubgroups;
1630+
}
1631+
15681632
#ifdef GRANITE_VULKAN_PROFILES
15691633
// Override any properties in the profile in strict mode.
15701634
if (profile.profile && required_profile_strict)

vulkan/context.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ struct DeviceFeatures
109109

110110
// Fallback feature structs (Vulkan 1.1)
111111
VkPhysicalDeviceHostQueryResetFeatures host_query_reset_features = {};
112+
VkPhysicalDevice16BitStorageFeaturesKHR storage_16bit_features = {};
113+
// Fallback feature structs (Vulkan 1.2)
114+
VkPhysicalDeviceFloat16Int8FeaturesKHR float16_int8_features = {};
115+
VkPhysicalDevice8BitStorageFeaturesKHR storage_8bit_features = {};
116+
// Fallback feature structs (Vulkan 1.3)
117+
VkPhysicalDeviceSubgroupSizeControlFeatures subgroup_size_control_features = {};
112118

113119
VkDriverId driver_id = {};
114120

0 commit comments

Comments
 (0)