@@ -60,10 +60,6 @@ static VkFormat getVKFormat(DataFormat Format, int Channels) {
6060 VKFormats (UINT , 64 ) break ;
6161 case DataFormat::Float64:
6262 VKFormats (SFLOAT , 64 ) break ;
63- case DataFormat::Depth32:
64- if (Channels != 1 )
65- llvm_unreachable (" Depth32 format only supports a single channel." );
66- return VK_FORMAT_D32_SFLOAT ;
6763 default :
6864 llvm_unreachable (" Unsupported Resource format specified" );
6965 }
@@ -3395,13 +3391,15 @@ class VulkanDevice : public offloadtest::Device {
33953391 llvm::Expected<ResourceRef> createImage (Resource &R, BufferRef &Host,
33963392 int UsageOverride = 0 ) {
33973393 const offloadtest::CPUBuffer &B = *R.BufferPtr ;
3398- if (B.Format == DataFormat::Depth32 && R.isReadWrite ())
3394+ const bool IsDepth = B.GpuFormat .has_value () && isDepthFormat (*B.GpuFormat );
3395+ if (IsDepth && R.isReadWrite ())
33993396 return llvm::createStringError (std::errc::invalid_argument,
34003397 " Image memory allocation failed." );
34013398 VkImageCreateInfo ImageCreateInfo = {};
34023399 ImageCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO ;
34033400 ImageCreateInfo.imageType = getVKImageType (R.Kind );
3404- ImageCreateInfo.format = getVKFormat (B.Format , B.Channels );
3401+ ImageCreateInfo.format = B.GpuFormat ? getVulkanFormat (*B.GpuFormat )
3402+ : getVKFormat (B.Format , B.Channels );
34053403 ImageCreateInfo.mipLevels = B.OutputProps .MipLevels ;
34063404 ImageCreateInfo.arrayLayers = 1 ;
34073405 ImageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT ;
@@ -3823,12 +3821,14 @@ class VulkanDevice : public offloadtest::Device {
38233821 ViewCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO ;
38243822 ViewCreateInfo.viewType = getImageViewType (R.Kind );
38253823 ViewCreateInfo.format =
3826- getVKFormat (R.BufferPtr ->Format , R.BufferPtr ->Channels );
3824+ R.BufferPtr ->GpuFormat
3825+ ? getVulkanFormat (*R.BufferPtr ->GpuFormat )
3826+ : getVKFormat (R.BufferPtr ->Format , R.BufferPtr ->Channels );
38273827 ViewCreateInfo.components = {
38283828 VK_COMPONENT_SWIZZLE_R , VK_COMPONENT_SWIZZLE_G ,
38293829 VK_COMPONENT_SWIZZLE_B , VK_COMPONENT_SWIZZLE_A };
38303830 ViewCreateInfo.subresourceRange .aspectMask =
3831- R.BufferPtr ->Format == DataFormat::Depth32
3831+ ( R.BufferPtr ->GpuFormat && isDepthFormat (*R. BufferPtr -> GpuFormat ))
38323832 ? VK_IMAGE_ASPECT_DEPTH_BIT
38333833 : VK_IMAGE_ASPECT_COLOR_BIT ;
38343834 ViewCreateInfo.subresourceRange .baseMipLevel = 0 ;
@@ -4086,13 +4086,14 @@ class VulkanDevice : public offloadtest::Device {
40864086 return ;
40874087 if (R.isImage ()) {
40884088 const offloadtest::CPUBuffer &B = *R.BufferPtr ;
4089+ const bool IsDepth =
4090+ B.GpuFormat .has_value () && isDepthFormat (*B.GpuFormat );
40894091 llvm::SmallVector<VkBufferImageCopy> Regions;
40904092 uint64_t CurrentOffset = 0 ;
40914093 for (int I = 0 ; I < B.OutputProps .MipLevels ; ++I) {
40924094 VkBufferImageCopy Region = {};
4093- Region.imageSubresource .aspectMask = B.Format == DataFormat::Depth32
4094- ? VK_IMAGE_ASPECT_DEPTH_BIT
4095- : VK_IMAGE_ASPECT_COLOR_BIT ;
4095+ Region.imageSubresource .aspectMask =
4096+ IsDepth ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT ;
40964097 Region.imageSubresource .mipLevel = I;
40974098 Region.imageSubresource .baseArrayLayer = 0 ;
40984099 Region.imageSubresource .layerCount = 1 ;
@@ -4110,9 +4111,8 @@ class VulkanDevice : public offloadtest::Device {
41104111 }
41114112
41124113 VkImageSubresourceRange SubRange = {};
4113- SubRange.aspectMask = B.Format == DataFormat::Depth32
4114- ? VK_IMAGE_ASPECT_DEPTH_BIT
4115- : VK_IMAGE_ASPECT_COLOR_BIT ;
4114+ SubRange.aspectMask =
4115+ IsDepth ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT ;
41164116 SubRange.baseMipLevel = 0 ;
41174117 SubRange.levelCount = B.OutputProps .MipLevels ;
41184118 SubRange.layerCount = 1 ;
@@ -4232,10 +4232,11 @@ class VulkanDevice : public offloadtest::Device {
42324232 return ;
42334233 if (R.isImage ()) {
42344234 const offloadtest::CPUBuffer &B = *R.BufferPtr ;
4235+ const bool IsDepth =
4236+ B.GpuFormat .has_value () && isDepthFormat (*B.GpuFormat );
42354237 VkImageSubresourceRange SubRange = {};
4236- SubRange.aspectMask = B.Format == DataFormat::Depth32
4237- ? VK_IMAGE_ASPECT_DEPTH_BIT
4238- : VK_IMAGE_ASPECT_COLOR_BIT ;
4238+ SubRange.aspectMask =
4239+ IsDepth ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT ;
42394240 SubRange.baseMipLevel = 0 ;
42404241 SubRange.levelCount = B.OutputProps .MipLevels ;
42414242 SubRange.layerCount = 1 ;
@@ -4262,9 +4263,8 @@ class VulkanDevice : public offloadtest::Device {
42624263 uint64_t CurrentOffset = 0 ;
42634264 for (int I = 0 ; I < B.OutputProps .MipLevels ; ++I) {
42644265 VkBufferImageCopy Region = {};
4265- Region.imageSubresource .aspectMask = B.Format == DataFormat::Depth32
4266- ? VK_IMAGE_ASPECT_DEPTH_BIT
4267- : VK_IMAGE_ASPECT_COLOR_BIT ;
4266+ Region.imageSubresource .aspectMask =
4267+ IsDepth ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT ;
42684268 Region.imageSubresource .mipLevel = I;
42694269 Region.imageSubresource .baseArrayLayer = 0 ;
42704270 Region.imageSubresource .layerCount = 1 ;
0 commit comments