From 3a7a77a7123222f0db92c8a0b42662ec0256b7dc Mon Sep 17 00:00:00 2001 From: Alex Sepkowski Date: Mon, 22 Jun 2026 11:45:49 -0700 Subject: [PATCH 1/4] [NFC] Express GPU texture formats via CPUBuffer GpuFormat field Replace the special-cased DataFormat::Depth32 enum value with a general CPUBuffer::GpuFormat field that names a GPU Format directly (e.g. D32Float), instead of inferring it from DataFormat + Channels via toFormat(). This removes the need to extend DataFormat for every special texture format and lets depth-format textures be expressed as a regular float buffer plus an explicit GpuFormat. The Vulkan backend now selects the image/view format and depth/color aspect from GpuFormat; the DX and Check paths drop the now-unused Depth32 cases. Existing GatherCmp/SampleCmp depth tests are migrated from "Format: Depth32" to "Format: Float32" + "GpuFormat: D32Float". No functional change intended. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- include/API/FormatConversion.h | 7 ---- include/Support/Pipeline.h | 8 ++-- lib/API/DX/Device.cpp | 8 +++- lib/API/VK/Device.cpp | 40 +++++++++---------- lib/Support/Check.cpp | 8 +--- lib/Support/Pipeline.cpp | 6 +-- .../Textures/Texture2D.GatherCmp.test.yaml | 3 +- .../Textures/Texture2D.SampleCmp.test.yaml | 3 +- .../Vk.SampledTexture2D.GatherCmp.test.yaml | 9 +++-- .../Vk.SampledTexture2D.SampleCmp.test.yaml | 6 ++- 10 files changed, 48 insertions(+), 50 deletions(-) diff --git a/include/API/FormatConversion.h b/include/API/FormatConversion.h index 096d6aaf4..763a88705 100644 --- a/include/API/FormatConversion.h +++ b/include/API/FormatConversion.h @@ -80,13 +80,6 @@ inline llvm::Expected toFormat(DataFormat Format, int Channels) { return Format::RGBA32Float; } break; - case DataFormat::Depth32: - // D32FloatS8Uint is not expressible as DataFormat + Channels because the - // stencil component is uint8, not a second Depth32 channel. Once the - // pipeline uses Format directly, this limitation goes away. - if (Channels == 1) - return Format::D32Float; - break; case DataFormat::UInt64: // Only 1 and 2 channels of 64-bit integers are supported. switch (Channels) { diff --git a/include/Support/Pipeline.h b/include/Support/Pipeline.h index 81ceeb985..f70afd7d1 100644 --- a/include/Support/Pipeline.h +++ b/include/Support/Pipeline.h @@ -107,7 +107,6 @@ enum class DataFormat { Float16, Float32, Float64, - Depth32, Bool, }; @@ -198,7 +197,6 @@ static inline uint32_t getFormatSize(DataFormat Format) { case DataFormat::UInt32: case DataFormat::Int32: case DataFormat::Float32: - case DataFormat::Depth32: case DataFormat::Bool: return 4; case DataFormat::Hex64: @@ -216,6 +214,11 @@ struct CPUBuffer { int Channels; int Stride; uint32_t ArraySize; + // When set, names the GPU texture format directly (e.g. D32Float) instead of + // inferring it from DataFormat + Channels via toFormat(). This lets depth + // buffers and other special formats be expressed without extending + // DataFormat. + std::optional GpuFormat; // Data can contain one block of data for a singular resource // or multiple blocks for a resource array. llvm::SmallVector> Data; @@ -931,7 +934,6 @@ template <> struct ScalarEnumerationTraits { ENUM_CASE(Float16); ENUM_CASE(Float32); ENUM_CASE(Float64); - ENUM_CASE(Depth32); ENUM_CASE(Bool); #undef ENUM_CASE } diff --git a/lib/API/DX/Device.cpp b/lib/API/DX/Device.cpp index 76d05f39e..dc48fd6c2 100644 --- a/lib/API/DX/Device.cpp +++ b/lib/API/DX/Device.cpp @@ -2559,9 +2559,13 @@ class DXDevice : public offloadtest::Device { "Multiple mip levels are not yet " "supported for DirectX textures."); - auto FormatOrErr = toFormat(R.BufferPtr->Format, R.BufferPtr->Channels); + auto FormatOrErr = + R.BufferPtr->GpuFormat + ? llvm::Expected(*R.BufferPtr->GpuFormat) + : toFormat(R.BufferPtr->Format, R.BufferPtr->Channels); if (!FormatOrErr) return FormatOrErr.takeError(); + const Format Fmt = *FormatOrErr; LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); @@ -2572,7 +2576,7 @@ class DXDevice : public offloadtest::Device { CreateDesc.Usage = TextureUsage::Sampled; if (R.Kind == ResourceKind::RWTexture2D) CreateDesc.Usage |= TextureUsage::Storage; - CreateDesc.Fmt = *FormatOrErr; + CreateDesc.Fmt = Fmt; CreateDesc.Width = R.BufferPtr->OutputProps.Width; CreateDesc.Height = R.BufferPtr->OutputProps.Height; CreateDesc.MipLevels = 1; diff --git a/lib/API/VK/Device.cpp b/lib/API/VK/Device.cpp index f12ccb9f7..7b916aad5 100644 --- a/lib/API/VK/Device.cpp +++ b/lib/API/VK/Device.cpp @@ -60,10 +60,6 @@ static VkFormat getVKFormat(DataFormat Format, int Channels) { VKFormats(UINT, 64) break; case DataFormat::Float64: VKFormats(SFLOAT, 64) break; - case DataFormat::Depth32: - if (Channels != 1) - llvm_unreachable("Depth32 format only supports a single channel."); - return VK_FORMAT_D32_SFLOAT; default: llvm_unreachable("Unsupported Resource format specified"); } @@ -3395,13 +3391,15 @@ class VulkanDevice : public offloadtest::Device { llvm::Expected createImage(Resource &R, BufferRef &Host, int UsageOverride = 0) { const offloadtest::CPUBuffer &B = *R.BufferPtr; - if (B.Format == DataFormat::Depth32 && R.isReadWrite()) + const bool IsDepth = B.GpuFormat.has_value() && isDepthFormat(*B.GpuFormat); + if (IsDepth && R.isReadWrite()) return llvm::createStringError(std::errc::invalid_argument, "Image memory allocation failed."); VkImageCreateInfo ImageCreateInfo = {}; ImageCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; ImageCreateInfo.imageType = getVKImageType(R.Kind); - ImageCreateInfo.format = getVKFormat(B.Format, B.Channels); + ImageCreateInfo.format = B.GpuFormat ? getVulkanFormat(*B.GpuFormat) + : getVKFormat(B.Format, B.Channels); ImageCreateInfo.mipLevels = B.OutputProps.MipLevels; ImageCreateInfo.arrayLayers = 1; ImageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT; @@ -3823,12 +3821,14 @@ class VulkanDevice : public offloadtest::Device { ViewCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; ViewCreateInfo.viewType = getImageViewType(R.Kind); ViewCreateInfo.format = - getVKFormat(R.BufferPtr->Format, R.BufferPtr->Channels); + R.BufferPtr->GpuFormat + ? getVulkanFormat(*R.BufferPtr->GpuFormat) + : getVKFormat(R.BufferPtr->Format, R.BufferPtr->Channels); ViewCreateInfo.components = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A}; ViewCreateInfo.subresourceRange.aspectMask = - R.BufferPtr->Format == DataFormat::Depth32 + (R.BufferPtr->GpuFormat && isDepthFormat(*R.BufferPtr->GpuFormat)) ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT; ViewCreateInfo.subresourceRange.baseMipLevel = 0; @@ -4086,13 +4086,14 @@ class VulkanDevice : public offloadtest::Device { return; if (R.isImage()) { const offloadtest::CPUBuffer &B = *R.BufferPtr; + const bool IsDepth = + B.GpuFormat.has_value() && isDepthFormat(*B.GpuFormat); llvm::SmallVector Regions; uint64_t CurrentOffset = 0; for (int I = 0; I < B.OutputProps.MipLevels; ++I) { VkBufferImageCopy Region = {}; - Region.imageSubresource.aspectMask = B.Format == DataFormat::Depth32 - ? VK_IMAGE_ASPECT_DEPTH_BIT - : VK_IMAGE_ASPECT_COLOR_BIT; + Region.imageSubresource.aspectMask = + IsDepth ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT; Region.imageSubresource.mipLevel = I; Region.imageSubresource.baseArrayLayer = 0; Region.imageSubresource.layerCount = 1; @@ -4110,9 +4111,8 @@ class VulkanDevice : public offloadtest::Device { } VkImageSubresourceRange SubRange = {}; - SubRange.aspectMask = B.Format == DataFormat::Depth32 - ? VK_IMAGE_ASPECT_DEPTH_BIT - : VK_IMAGE_ASPECT_COLOR_BIT; + SubRange.aspectMask = + IsDepth ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT; SubRange.baseMipLevel = 0; SubRange.levelCount = B.OutputProps.MipLevels; SubRange.layerCount = 1; @@ -4232,10 +4232,11 @@ class VulkanDevice : public offloadtest::Device { return; if (R.isImage()) { const offloadtest::CPUBuffer &B = *R.BufferPtr; + const bool IsDepth = + B.GpuFormat.has_value() && isDepthFormat(*B.GpuFormat); VkImageSubresourceRange SubRange = {}; - SubRange.aspectMask = B.Format == DataFormat::Depth32 - ? VK_IMAGE_ASPECT_DEPTH_BIT - : VK_IMAGE_ASPECT_COLOR_BIT; + SubRange.aspectMask = + IsDepth ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT; SubRange.baseMipLevel = 0; SubRange.levelCount = B.OutputProps.MipLevels; SubRange.layerCount = 1; @@ -4262,9 +4263,8 @@ class VulkanDevice : public offloadtest::Device { uint64_t CurrentOffset = 0; for (int I = 0; I < B.OutputProps.MipLevels; ++I) { VkBufferImageCopy Region = {}; - Region.imageSubresource.aspectMask = B.Format == DataFormat::Depth32 - ? VK_IMAGE_ASPECT_DEPTH_BIT - : VK_IMAGE_ASPECT_COLOR_BIT; + Region.imageSubresource.aspectMask = + IsDepth ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT; Region.imageSubresource.mipLevel = I; Region.imageSubresource.baseArrayLayer = 0; Region.imageSubresource.layerCount = 1; diff --git a/lib/Support/Check.cpp b/lib/Support/Check.cpp index f9b94a783..e25dad60a 100644 --- a/lib/Support/Check.cpp +++ b/lib/Support/Check.cpp @@ -228,7 +228,6 @@ testBufferFloat(std::function ComparisonFn, case offloadtest::DataFormat::Float64: return testAllArray(ComparisonFn, B1, B2); case offloadtest::DataFormat::Float32: - case offloadtest::DataFormat::Depth32: return testAllArray(ComparisonFn, B1, B2); case offloadtest::DataFormat::Float16: { return testAllArray(ComparisonFn, B1, B2); @@ -250,8 +249,7 @@ static bool testBufferFloatEpsilon(offloadtest::CPUBuffer *B1, }; return testBufferFloat(Fn, B1, B2); } - case offloadtest::DataFormat::Float32: - case offloadtest::DataFormat::Depth32: { + case offloadtest::DataFormat::Float32: { auto Fn = [Epsilon, DM](const float &FS, const float &FR) { return compareFloatEpsilon(FS, FR, (float)Epsilon, DM); }; @@ -280,8 +278,7 @@ static bool testBufferFloatULP(offloadtest::CPUBuffer *B1, }; return testBufferFloat(Fn, B1, B2); } - case offloadtest::DataFormat::Float32: - case offloadtest::DataFormat::Depth32: { + case offloadtest::DataFormat::Float32: { auto Fn = [ULPT, DM](const float &FS, const float &FR) { return compareFloatULP(FS, FR, ULPT, DM); }; @@ -379,7 +376,6 @@ static const std::string getBufferStr(offloadtest::CPUBuffer *B) { case DF::Float16: return formatBuffer(B); // assuming no native float16 case DF::Float32: - case DF::Depth32: return formatBuffer(B); case DF::Float64: return formatBuffer(B); diff --git a/lib/Support/Pipeline.cpp b/lib/Support/Pipeline.cpp index 1d0c566b6..1019be676 100644 --- a/lib/Support/Pipeline.cpp +++ b/lib/Support/Pipeline.cpp @@ -363,6 +363,7 @@ void MappingTraits::mapping(IO &I, I.mapRequired("Name", B.Name); I.mapRequired("Format", B.Format); I.mapOptional("Channels", B.Channels, 1); + I.mapOptional("GpuFormat", B.GpuFormat); I.mapOptional("Stride", B.Stride, 0); I.mapOptional("ArraySize", B.ArraySize, 1); setCounters(I, B); @@ -407,9 +408,6 @@ void MappingTraits::mapping(IO &I, case DF::Float32: setData(I, B); break; - case DF::Depth32: - setData(I, B); - break; case DF::Float64: setData(I, B); break; @@ -528,8 +526,6 @@ void MappingTraits::mapping( return setData(I, B); // assuming no native float16 case DF::Float32: return setData(I, B); - case DF::Depth32: - return setData(I, B); case DF::Float64: return setData(I, B); case DF::Bool: diff --git a/test/Feature/Textures/Texture2D.GatherCmp.test.yaml b/test/Feature/Textures/Texture2D.GatherCmp.test.yaml index 9a950a6c8..416b141e8 100644 --- a/test/Feature/Textures/Texture2D.GatherCmp.test.yaml +++ b/test/Feature/Textures/Texture2D.GatherCmp.test.yaml @@ -68,7 +68,8 @@ Shaders: Buffers: - Name: Tex - Format: Depth32 + Format: Float32 + GpuFormat: D32Float Channels: 1 OutputProps: { Width: 2, Height: 2, Depth: 1 } Data: [ 0.2, # (0,0) R=0.2 diff --git a/test/Feature/Textures/Texture2D.SampleCmp.test.yaml b/test/Feature/Textures/Texture2D.SampleCmp.test.yaml index 52a06c512..2de485fec 100644 --- a/test/Feature/Textures/Texture2D.SampleCmp.test.yaml +++ b/test/Feature/Textures/Texture2D.SampleCmp.test.yaml @@ -107,7 +107,8 @@ Shaders: Buffers: - Name: Tex - Format: Depth32 + Format: Float32 + GpuFormat: D32Float Channels: 1 OutputProps: { Width: 2, Height: 2, Depth: 1 } Data: [ 0.2, # (0,0) -> 0.2 diff --git a/test/Feature/Vk.SampledTextures/Vk.SampledTexture2D/Vk.SampledTexture2D.GatherCmp.test.yaml b/test/Feature/Vk.SampledTextures/Vk.SampledTexture2D/Vk.SampledTexture2D.GatherCmp.test.yaml index b37435331..2299606d3 100644 --- a/test/Feature/Vk.SampledTextures/Vk.SampledTexture2D/Vk.SampledTexture2D.GatherCmp.test.yaml +++ b/test/Feature/Vk.SampledTextures/Vk.SampledTexture2D/Vk.SampledTexture2D.GatherCmp.test.yaml @@ -49,7 +49,8 @@ Shaders: Buffers: - Name: SampledTexLess - Format: Depth32 + Format: Float32 + GpuFormat: D32Float Channels: 1 OutputProps: { Width: 2, Height: 2, Depth: 1 } Data: [ 0.2, # (0,0) R=0.2 @@ -58,7 +59,8 @@ Buffers: 0.8 ] # (1,1) R=0.8 - Name: SampledTexGreater - Format: Depth32 + Format: Float32 + GpuFormat: D32Float Channels: 1 OutputProps: { Width: 2, Height: 2, Depth: 1 } Data: [ 0.2, @@ -67,7 +69,8 @@ Buffers: 0.8 ] - Name: SampledTexRepeat - Format: Depth32 + Format: Float32 + GpuFormat: D32Float Channels: 1 OutputProps: { Width: 2, Height: 2, Depth: 1 } Data: [ 0.2, diff --git a/test/Feature/Vk.SampledTextures/Vk.SampledTexture2D/Vk.SampledTexture2D.SampleCmp.test.yaml b/test/Feature/Vk.SampledTextures/Vk.SampledTexture2D/Vk.SampledTexture2D.SampleCmp.test.yaml index 7d9a605bc..49f775c7c 100644 --- a/test/Feature/Vk.SampledTextures/Vk.SampledTexture2D/Vk.SampledTexture2D.SampleCmp.test.yaml +++ b/test/Feature/Vk.SampledTextures/Vk.SampledTexture2D/Vk.SampledTexture2D.SampleCmp.test.yaml @@ -88,7 +88,8 @@ Shaders: Buffers: - Name: SampledTexLess - Format: Depth32 + Format: Float32 + GpuFormat: D32Float Channels: 1 OutputProps: { Width: 2, Height: 2, Depth: 1 } Data: [ 0.2, # (0,0) -> 0.2 @@ -97,7 +98,8 @@ Buffers: 0.8 ] # (1,1) -> 0.8 - Name: SampledTexGreater - Format: Depth32 + Format: Float32 + GpuFormat: D32Float Channels: 1 OutputProps: { Width: 2, Height: 2, Depth: 1 } Data: [ 0.2, From 82cf91bcc418ddcc7129f1f01be12fc47e65f1c8 Mon Sep 17 00:00:00 2001 From: Alex Sepkowski Date: Mon, 22 Jun 2026 15:36:32 -0700 Subject: [PATCH 2/4] Simplify DX format selection by using FormatOrErr directly Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- lib/API/DX/Device.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/API/DX/Device.cpp b/lib/API/DX/Device.cpp index dc48fd6c2..3dba52944 100644 --- a/lib/API/DX/Device.cpp +++ b/lib/API/DX/Device.cpp @@ -2565,7 +2565,6 @@ class DXDevice : public offloadtest::Device { : toFormat(R.BufferPtr->Format, R.BufferPtr->Channels); if (!FormatOrErr) return FormatOrErr.takeError(); - const Format Fmt = *FormatOrErr; LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); @@ -2576,7 +2575,7 @@ class DXDevice : public offloadtest::Device { CreateDesc.Usage = TextureUsage::Sampled; if (R.Kind == ResourceKind::RWTexture2D) CreateDesc.Usage |= TextureUsage::Storage; - CreateDesc.Fmt = Fmt; + CreateDesc.Fmt = *FormatOrErr; CreateDesc.Width = R.BufferPtr->OutputProps.Width; CreateDesc.Height = R.BufferPtr->OutputProps.Height; CreateDesc.MipLevels = 1; From 49c7a1a6ad8cc3983ffc754ed017e9e19843bd37 Mon Sep 17 00:00:00 2001 From: Alex Sepkowski Date: Mon, 22 Jun 2026 20:42:33 -0700 Subject: [PATCH 3/4] Rename GpuFormat to GPUFormat to match CPU/GPU acronym casing Addresses review feedback on PR #1327: use all-caps GPU acronym to match CPUBuffer naming, across the CPUBuffer field, the YAML key, and tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- include/Support/Pipeline.h | 2 +- lib/API/DX/Device.cpp | 4 ++-- lib/API/VK/Device.cpp | 14 +++++++------- lib/Support/Pipeline.cpp | 2 +- .../Feature/Textures/Texture2D.GatherCmp.test.yaml | 2 +- .../Feature/Textures/Texture2D.SampleCmp.test.yaml | 2 +- .../Vk.SampledTexture2D.GatherCmp.test.yaml | 6 +++--- .../Vk.SampledTexture2D.SampleCmp.test.yaml | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/Support/Pipeline.h b/include/Support/Pipeline.h index f70afd7d1..09bba09e4 100644 --- a/include/Support/Pipeline.h +++ b/include/Support/Pipeline.h @@ -218,7 +218,7 @@ struct CPUBuffer { // inferring it from DataFormat + Channels via toFormat(). This lets depth // buffers and other special formats be expressed without extending // DataFormat. - std::optional GpuFormat; + std::optional GPUFormat; // Data can contain one block of data for a singular resource // or multiple blocks for a resource array. llvm::SmallVector> Data; diff --git a/lib/API/DX/Device.cpp b/lib/API/DX/Device.cpp index 3dba52944..2a33f8d2b 100644 --- a/lib/API/DX/Device.cpp +++ b/lib/API/DX/Device.cpp @@ -2560,8 +2560,8 @@ class DXDevice : public offloadtest::Device { "supported for DirectX textures."); auto FormatOrErr = - R.BufferPtr->GpuFormat - ? llvm::Expected(*R.BufferPtr->GpuFormat) + R.BufferPtr->GPUFormat + ? llvm::Expected(*R.BufferPtr->GPUFormat) : toFormat(R.BufferPtr->Format, R.BufferPtr->Channels); if (!FormatOrErr) return FormatOrErr.takeError(); diff --git a/lib/API/VK/Device.cpp b/lib/API/VK/Device.cpp index 7b916aad5..1e520dc20 100644 --- a/lib/API/VK/Device.cpp +++ b/lib/API/VK/Device.cpp @@ -3391,14 +3391,14 @@ class VulkanDevice : public offloadtest::Device { llvm::Expected createImage(Resource &R, BufferRef &Host, int UsageOverride = 0) { const offloadtest::CPUBuffer &B = *R.BufferPtr; - const bool IsDepth = B.GpuFormat.has_value() && isDepthFormat(*B.GpuFormat); + const bool IsDepth = B.GPUFormat.has_value() && isDepthFormat(*B.GPUFormat); if (IsDepth && R.isReadWrite()) return llvm::createStringError(std::errc::invalid_argument, "Image memory allocation failed."); VkImageCreateInfo ImageCreateInfo = {}; ImageCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; ImageCreateInfo.imageType = getVKImageType(R.Kind); - ImageCreateInfo.format = B.GpuFormat ? getVulkanFormat(*B.GpuFormat) + ImageCreateInfo.format = B.GPUFormat ? getVulkanFormat(*B.GPUFormat) : getVKFormat(B.Format, B.Channels); ImageCreateInfo.mipLevels = B.OutputProps.MipLevels; ImageCreateInfo.arrayLayers = 1; @@ -3821,14 +3821,14 @@ class VulkanDevice : public offloadtest::Device { ViewCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; ViewCreateInfo.viewType = getImageViewType(R.Kind); ViewCreateInfo.format = - R.BufferPtr->GpuFormat - ? getVulkanFormat(*R.BufferPtr->GpuFormat) + R.BufferPtr->GPUFormat + ? getVulkanFormat(*R.BufferPtr->GPUFormat) : getVKFormat(R.BufferPtr->Format, R.BufferPtr->Channels); ViewCreateInfo.components = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A}; ViewCreateInfo.subresourceRange.aspectMask = - (R.BufferPtr->GpuFormat && isDepthFormat(*R.BufferPtr->GpuFormat)) + (R.BufferPtr->GPUFormat && isDepthFormat(*R.BufferPtr->GPUFormat)) ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT; ViewCreateInfo.subresourceRange.baseMipLevel = 0; @@ -4087,7 +4087,7 @@ class VulkanDevice : public offloadtest::Device { if (R.isImage()) { const offloadtest::CPUBuffer &B = *R.BufferPtr; const bool IsDepth = - B.GpuFormat.has_value() && isDepthFormat(*B.GpuFormat); + B.GPUFormat.has_value() && isDepthFormat(*B.GPUFormat); llvm::SmallVector Regions; uint64_t CurrentOffset = 0; for (int I = 0; I < B.OutputProps.MipLevels; ++I) { @@ -4233,7 +4233,7 @@ class VulkanDevice : public offloadtest::Device { if (R.isImage()) { const offloadtest::CPUBuffer &B = *R.BufferPtr; const bool IsDepth = - B.GpuFormat.has_value() && isDepthFormat(*B.GpuFormat); + B.GPUFormat.has_value() && isDepthFormat(*B.GPUFormat); VkImageSubresourceRange SubRange = {}; SubRange.aspectMask = IsDepth ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT; diff --git a/lib/Support/Pipeline.cpp b/lib/Support/Pipeline.cpp index 1019be676..c93a0ba03 100644 --- a/lib/Support/Pipeline.cpp +++ b/lib/Support/Pipeline.cpp @@ -363,7 +363,7 @@ void MappingTraits::mapping(IO &I, I.mapRequired("Name", B.Name); I.mapRequired("Format", B.Format); I.mapOptional("Channels", B.Channels, 1); - I.mapOptional("GpuFormat", B.GpuFormat); + I.mapOptional("GPUFormat", B.GPUFormat); I.mapOptional("Stride", B.Stride, 0); I.mapOptional("ArraySize", B.ArraySize, 1); setCounters(I, B); diff --git a/test/Feature/Textures/Texture2D.GatherCmp.test.yaml b/test/Feature/Textures/Texture2D.GatherCmp.test.yaml index 416b141e8..980c1dbe6 100644 --- a/test/Feature/Textures/Texture2D.GatherCmp.test.yaml +++ b/test/Feature/Textures/Texture2D.GatherCmp.test.yaml @@ -69,7 +69,7 @@ Shaders: Buffers: - Name: Tex Format: Float32 - GpuFormat: D32Float + GPUFormat: D32Float Channels: 1 OutputProps: { Width: 2, Height: 2, Depth: 1 } Data: [ 0.2, # (0,0) R=0.2 diff --git a/test/Feature/Textures/Texture2D.SampleCmp.test.yaml b/test/Feature/Textures/Texture2D.SampleCmp.test.yaml index 2de485fec..dae6d1278 100644 --- a/test/Feature/Textures/Texture2D.SampleCmp.test.yaml +++ b/test/Feature/Textures/Texture2D.SampleCmp.test.yaml @@ -108,7 +108,7 @@ Shaders: Buffers: - Name: Tex Format: Float32 - GpuFormat: D32Float + GPUFormat: D32Float Channels: 1 OutputProps: { Width: 2, Height: 2, Depth: 1 } Data: [ 0.2, # (0,0) -> 0.2 diff --git a/test/Feature/Vk.SampledTextures/Vk.SampledTexture2D/Vk.SampledTexture2D.GatherCmp.test.yaml b/test/Feature/Vk.SampledTextures/Vk.SampledTexture2D/Vk.SampledTexture2D.GatherCmp.test.yaml index 2299606d3..f44589dcd 100644 --- a/test/Feature/Vk.SampledTextures/Vk.SampledTexture2D/Vk.SampledTexture2D.GatherCmp.test.yaml +++ b/test/Feature/Vk.SampledTextures/Vk.SampledTexture2D/Vk.SampledTexture2D.GatherCmp.test.yaml @@ -50,7 +50,7 @@ Shaders: Buffers: - Name: SampledTexLess Format: Float32 - GpuFormat: D32Float + GPUFormat: D32Float Channels: 1 OutputProps: { Width: 2, Height: 2, Depth: 1 } Data: [ 0.2, # (0,0) R=0.2 @@ -60,7 +60,7 @@ Buffers: - Name: SampledTexGreater Format: Float32 - GpuFormat: D32Float + GPUFormat: D32Float Channels: 1 OutputProps: { Width: 2, Height: 2, Depth: 1 } Data: [ 0.2, @@ -70,7 +70,7 @@ Buffers: - Name: SampledTexRepeat Format: Float32 - GpuFormat: D32Float + GPUFormat: D32Float Channels: 1 OutputProps: { Width: 2, Height: 2, Depth: 1 } Data: [ 0.2, diff --git a/test/Feature/Vk.SampledTextures/Vk.SampledTexture2D/Vk.SampledTexture2D.SampleCmp.test.yaml b/test/Feature/Vk.SampledTextures/Vk.SampledTexture2D/Vk.SampledTexture2D.SampleCmp.test.yaml index 49f775c7c..03d834df6 100644 --- a/test/Feature/Vk.SampledTextures/Vk.SampledTexture2D/Vk.SampledTexture2D.SampleCmp.test.yaml +++ b/test/Feature/Vk.SampledTextures/Vk.SampledTexture2D/Vk.SampledTexture2D.SampleCmp.test.yaml @@ -89,7 +89,7 @@ Shaders: Buffers: - Name: SampledTexLess Format: Float32 - GpuFormat: D32Float + GPUFormat: D32Float Channels: 1 OutputProps: { Width: 2, Height: 2, Depth: 1 } Data: [ 0.2, # (0,0) -> 0.2 @@ -99,7 +99,7 @@ Buffers: - Name: SampledTexGreater Format: Float32 - GpuFormat: D32Float + GPUFormat: D32Float Channels: 1 OutputProps: { Width: 2, Height: 2, Depth: 1 } Data: [ 0.2, From 0e383eadea97d072766d2bba3dfdee8ae51dbf75 Mon Sep 17 00:00:00 2001 From: Alex Sepkowski Date: Mon, 22 Jun 2026 20:56:36 -0700 Subject: [PATCH 4/4] Use truthy optional check for IsDepth instead of has_value() Addresses review feedback on PR #1327: prefer 'B.GPUFormat && isDepthFormat(*B.GPUFormat)' for consistency with the existing image-view check. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- lib/API/VK/Device.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/API/VK/Device.cpp b/lib/API/VK/Device.cpp index 1e520dc20..fccbdf194 100644 --- a/lib/API/VK/Device.cpp +++ b/lib/API/VK/Device.cpp @@ -3391,7 +3391,7 @@ class VulkanDevice : public offloadtest::Device { llvm::Expected createImage(Resource &R, BufferRef &Host, int UsageOverride = 0) { const offloadtest::CPUBuffer &B = *R.BufferPtr; - const bool IsDepth = B.GPUFormat.has_value() && isDepthFormat(*B.GPUFormat); + const bool IsDepth = B.GPUFormat && isDepthFormat(*B.GPUFormat); if (IsDepth && R.isReadWrite()) return llvm::createStringError(std::errc::invalid_argument, "Image memory allocation failed."); @@ -4086,8 +4086,7 @@ class VulkanDevice : public offloadtest::Device { return; if (R.isImage()) { const offloadtest::CPUBuffer &B = *R.BufferPtr; - const bool IsDepth = - B.GPUFormat.has_value() && isDepthFormat(*B.GPUFormat); + const bool IsDepth = B.GPUFormat && isDepthFormat(*B.GPUFormat); llvm::SmallVector Regions; uint64_t CurrentOffset = 0; for (int I = 0; I < B.OutputProps.MipLevels; ++I) { @@ -4232,8 +4231,7 @@ class VulkanDevice : public offloadtest::Device { return; if (R.isImage()) { const offloadtest::CPUBuffer &B = *R.BufferPtr; - const bool IsDepth = - B.GPUFormat.has_value() && isDepthFormat(*B.GPUFormat); + const bool IsDepth = B.GPUFormat && isDepthFormat(*B.GPUFormat); VkImageSubresourceRange SubRange = {}; SubRange.aspectMask = IsDepth ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT;