Skip to content

Commit

Permalink
enable uniform 16bit and 8bit when available, fix validation error in…
Browse files Browse the repository at this point in the history
… fp16sa shader (#5233)
  • Loading branch information
nihui authored Dec 19, 2023
1 parent b11a9d1 commit 8c4fc5e
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1850,8 +1850,22 @@ int create_gpu_instance(const char* driver_path)
}
if (gpu_info.support_VK_KHR_shader_float16_int8)
{
gpu_info.support_fp16_arithmetic = queryFloat16Int8Features.shaderFloat16;
gpu_info.support_int8_arithmetic = queryFloat16Int8Features.shaderInt8;
if (gpu_info.support_fp16_storage)
{
gpu_info.support_fp16_arithmetic = queryFloat16Int8Features.shaderFloat16 && query16BitStorageFeatures.uniformAndStorageBuffer16BitAccess;
}
else
{
gpu_info.support_fp16_arithmetic = queryFloat16Int8Features.shaderFloat16;
}
if (gpu_info.support_int8_storage)
{
gpu_info.support_int8_arithmetic = queryFloat16Int8Features.shaderInt8 && query8BitStorageFeatures.uniformAndStorageBuffer8BitAccess;
}
else
{
gpu_info.support_int8_arithmetic = queryFloat16Int8Features.shaderInt8;
}
}
if (gpu_info.support_VK_KHR_sampler_ycbcr_conversion)
{
Expand Down Expand Up @@ -2444,7 +2458,7 @@ VulkanDevice::VulkanDevice(int device_index)
enabled8BitStorageFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR;
enabled8BitStorageFeatures.pNext = 0;
enabled8BitStorageFeatures.storageBuffer8BitAccess = info.support_int8_storage();
enabled8BitStorageFeatures.uniformAndStorageBuffer8BitAccess = VK_FALSE;
enabled8BitStorageFeatures.uniformAndStorageBuffer8BitAccess = info.support_int8_storage() && info.support_int8_arithmetic();
enabled8BitStorageFeatures.storagePushConstant8 = VK_FALSE;
if (support_VK_KHR_get_physical_device_properties2 && info.support_VK_KHR_8bit_storage())
{
Expand All @@ -2457,7 +2471,7 @@ VulkanDevice::VulkanDevice(int device_index)
enabled16BitStorageFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR;
enabled16BitStorageFeatures.pNext = 0;
enabled16BitStorageFeatures.storageBuffer16BitAccess = info.support_fp16_storage();
enabled16BitStorageFeatures.uniformAndStorageBuffer16BitAccess = VK_FALSE;
enabled16BitStorageFeatures.uniformAndStorageBuffer16BitAccess = info.support_fp16_storage() && info.support_fp16_arithmetic();
enabled16BitStorageFeatures.storagePushConstant16 = VK_FALSE;
enabled16BitStorageFeatures.storageInputOutput16 = VK_FALSE;
if (support_VK_KHR_get_physical_device_properties2 && info.support_VK_KHR_16bit_storage())
Expand Down

0 comments on commit 8c4fc5e

Please sign in to comment.