Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e112002

Browse files
MarijnS95claude
andauthored
Fix -Wchanges-meaning errors from newer GCC (#1095)
GCC 15 treats `-Wchanges-meaning` as an error, which fires when a struct member declaration shadows its own type name (e.g. `Format Format;` or `std::unique_ptr<Fence> Fence;`). CMake selects GCC as the default compiler on Linux when both GCC and Clang are installed, so the `OffloadTest` library fails to build on distros shipping GCC 15 (e.g. Arch Linux). The shadowing was introduced by: - PR #1020 (Introduce a new `Texture` type): `Format Format;` in `TextureCreateDesc` - PR #1007 (Implement an abstract `Fence` type): `unique_ptr<Fence> Fence;` in `InvocationState` (all backends) Rename the offending members to break the shadowing: - `TextureCreateDesc::Format` -> `TextureCreateDesc::Fmt` - `InvocationState::Fence` -> `InvocationState::CompletionFence` (all backends) Co-authored-by: Claude Opus 4.6 <[email protected]>
1 parent 4380b48 commit e112002

6 files changed

Lines changed: 32 additions & 32 deletions

File tree

include/API/FormatConversion.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ validateTextureDescMatchesCPUBuffer(const TextureCreateDesc &Desc,
114114
auto ExpectedFmt = toFormat(Buf.Format, Buf.Channels);
115115
if (!ExpectedFmt)
116116
return ExpectedFmt.takeError();
117-
if (Desc.Format != *ExpectedFmt)
117+
if (Desc.Fmt != *ExpectedFmt)
118118
return llvm::createStringError(
119119
std::errc::invalid_argument,
120120
"TextureCreateDesc format '%s' does not match CPUBuffer format "
121121
"(DataFormat %d, %d channels -> '%s').",
122-
getFormatName(Desc.Format).data(), static_cast<int>(Buf.Format),
122+
getFormatName(Desc.Fmt).data(), static_cast<int>(Buf.Format),
123123
Buf.Channels, getFormatName(*ExpectedFmt).data());
124124
if (Desc.Width != static_cast<uint32_t>(Buf.OutputProps.Width))
125125
return llvm::createStringError(
@@ -137,7 +137,7 @@ validateTextureDescMatchesCPUBuffer(const TextureCreateDesc &Desc,
137137
"TextureCreateDesc mip levels %u does not match CPUBuffer mip "
138138
"levels %d.",
139139
Desc.MipLevels, Buf.OutputProps.MipLevels);
140-
const uint32_t TexelSize = getFormatSizeInBytes(Desc.Format);
140+
const uint32_t TexelSize = getFormatSizeInBytes(Desc.Fmt);
141141
if (Buf.Stride > 0 && static_cast<uint32_t>(Buf.Stride) != TexelSize)
142142
return llvm::createStringError(
143143
std::errc::invalid_argument,

include/API/Texture.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ using ClearValue = std::variant<ClearColor, ClearDepthStencil>;
6565
struct TextureCreateDesc {
6666
MemoryLocation Location;
6767
TextureUsage Usage;
68-
Format Format;
68+
Format Fmt;
6969
uint32_t Width;
7070
uint32_t Height;
7171
uint32_t MipLevels;
@@ -77,13 +77,13 @@ struct TextureCreateDesc {
7777
};
7878

7979
inline llvm::Error validateTextureCreateDesc(const TextureCreateDesc &Desc) {
80-
if (!isTextureCompatible(Desc.Format))
80+
if (!isTextureCompatible(Desc.Fmt))
8181
return llvm::createStringError(
8282
std::errc::invalid_argument,
8383
"Format '%s' is not compatible with texture creation.",
84-
getFormatName(Desc.Format).data());
84+
getFormatName(Desc.Fmt).data());
8585

86-
const bool IsDepth = isDepthFormat(Desc.Format);
86+
const bool IsDepth = isDepthFormat(Desc.Fmt);
8787
const bool IsRT = (Desc.Usage & TextureUsage::RenderTarget) != 0;
8888
const bool IsDS = (Desc.Usage & TextureUsage::DepthStencil) != 0;
8989

@@ -104,12 +104,12 @@ inline llvm::Error validateTextureCreateDesc(const TextureCreateDesc &Desc) {
104104
return llvm::createStringError(
105105
std::errc::invalid_argument,
106106
"Depth format '%s' requires DepthStencil usage.",
107-
getFormatName(Desc.Format).data());
107+
getFormatName(Desc.Fmt).data());
108108
if (!IsDepth && IsDS)
109109
return llvm::createStringError(
110110
std::errc::invalid_argument,
111111
"DepthStencil usage requires a depth format, got '%s'.",
112-
getFormatName(Desc.Format).data());
112+
getFormatName(Desc.Fmt).data());
113113

114114
// Render targets and depth/stencil textures only support a single mip level.
115115
if ((IsRT || IsDS) && Desc.MipLevels != 1)

lib/API/DX/Device.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ class DXDevice : public offloadtest::Device {
476476
ComPtr<ID3D12DescriptorHeap> DescHeap;
477477
ComPtr<ID3D12PipelineState> PSO;
478478
std::unique_ptr<DXCommandBuffer> CB;
479-
std::unique_ptr<offloadtest::Fence> Fence;
479+
std::unique_ptr<offloadtest::Fence> CompletionFence;
480480

481481
// Resources for graphics pipelines.
482482
std::shared_ptr<DXTexture> RT;
@@ -556,7 +556,7 @@ class DXDevice : public offloadtest::Device {
556556
TexDesc.Height = Desc.Height;
557557
TexDesc.DepthOrArraySize = 1;
558558
TexDesc.MipLevels = static_cast<UINT16>(Desc.MipLevels);
559-
TexDesc.Format = getDXGIFormat(Desc.Format);
559+
TexDesc.Format = getDXGIFormat(Desc.Fmt);
560560
TexDesc.SampleDesc.Count = 1;
561561
TexDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
562562
TexDesc.Flags = getDXResourceFlags(Desc.Usage);
@@ -1340,14 +1340,14 @@ class DXDevice : public offloadtest::Device {
13401340
// This is a hack but it works since this is all single threaded code.
13411341
static uint64_t FenceCounter = 0;
13421342
const uint64_t CurrentCounter = FenceCounter + 1;
1343-
auto *F = static_cast<DXFence *>(IS.Fence.get());
1343+
auto *F = static_cast<DXFence *>(IS.CompletionFence.get());
13441344

13451345
if (auto Err = HR::toError(
13461346
GraphicsQueue.Queue->Signal(F->Fence.Get(), CurrentCounter),
13471347
"Failed to add signal."))
13481348
return Err;
13491349

1350-
if (auto Err = IS.Fence->waitForCompletion(CurrentCounter))
1350+
if (auto Err = IS.CompletionFence->waitForCompletion(CurrentCounter))
13511351
return Err;
13521352

13531353
FenceCounter = CurrentCounter;
@@ -1682,7 +1682,7 @@ class DXDevice : public offloadtest::Device {
16821682
PSODesc.DepthStencilState.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL;
16831683
PSODesc.DepthStencilState.DepthFunc = D3D12_COMPARISON_FUNC_LESS;
16841684
PSODesc.DepthStencilState.StencilEnable = false;
1685-
PSODesc.DSVFormat = getDXGIFormat(IS.DS->Desc.Format);
1685+
PSODesc.DSVFormat = getDXGIFormat(IS.DS->Desc.Fmt);
16861686
PSODesc.SampleMask = UINT_MAX;
16871687
PSODesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
16881688
PSODesc.NumRenderTargets = 1;
@@ -1840,7 +1840,7 @@ class DXDevice : public offloadtest::Device {
18401840
auto FenceOrErr = createFence("Fence");
18411841
if (!FenceOrErr)
18421842
return FenceOrErr.takeError();
1843-
State.Fence = std::move(*FenceOrErr);
1843+
State.CompletionFence = std::move(*FenceOrErr);
18441844

18451845
if (auto Err = createBuffers(P, State))
18461846
return Err;

lib/API/Device.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ offloadtest::createRenderTargetFromCPUBuffer(Device &Dev,
7575
TextureCreateDesc Desc = {};
7676
Desc.Location = MemoryLocation::GpuOnly;
7777
Desc.Usage = TextureUsage::RenderTarget;
78-
Desc.Format = *TexFmtOrErr;
78+
Desc.Fmt = *TexFmtOrErr;
7979
Desc.Width = Buf.OutputProps.Width;
8080
Desc.Height = Buf.OutputProps.Height;
8181
Desc.MipLevels = 1;
@@ -93,7 +93,7 @@ offloadtest::createDefaultDepthStencilTarget(Device &Dev, uint32_t Width,
9393
TextureCreateDesc Desc = {};
9494
Desc.Location = MemoryLocation::GpuOnly;
9595
Desc.Usage = TextureUsage::DepthStencil;
96-
Desc.Format = Format::D32FloatS8Uint;
96+
Desc.Fmt = Format::D32FloatS8Uint;
9797
Desc.Width = Width;
9898
Desc.Height = Height;
9999
Desc.MipLevels = 1;

lib/API/MTL/MTLDevice.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class MTLDevice : public offloadtest::Device {
204204
std::shared_ptr<MTLBuffer> FrameBufferReadback;
205205
std::shared_ptr<MTLTexture> DepthStencil;
206206
std::unique_ptr<MTLCommandBuffer> CB;
207-
std::unique_ptr<offloadtest::Fence> Fence;
207+
std::unique_ptr<offloadtest::Fence> CompletionFence;
208208
};
209209

210210
llvm::Error setupVertexShader(InvocationState &IS, const Pipeline &P,
@@ -632,7 +632,7 @@ class MTLDevice : public offloadtest::Device {
632632
// Blit the render target into the readback buffer for CPU access.
633633
MTL::BlitCommandEncoder *Blit = IS.CB->CmdBuffer->blitCommandEncoder();
634634
const size_t ElemSize =
635-
getFormatSizeInBytes(IS.FrameBufferTexture->Desc.Format);
635+
getFormatSizeInBytes(IS.FrameBufferTexture->Desc.Fmt);
636636
const size_t RowBytes = Width * ElemSize;
637637
Blit->copyFromTexture(IS.FrameBufferTexture->Tex, 0, 0,
638638
MTL::Origin(0, 0, 0), MTL::Size(Width, Height, 1),
@@ -646,12 +646,12 @@ class MTLDevice : public offloadtest::Device {
646646
// This is a hack but it works since this is all single threaded code.
647647
static uint64_t FenceCounter = 0;
648648
const uint64_t CurrentCounter = FenceCounter + 1;
649-
auto *F = static_cast<MTLFence *>(IS.Fence.get());
649+
auto *F = static_cast<MTLFence *>(IS.CompletionFence.get());
650650

651651
IS.CB->CmdBuffer->encodeSignalEvent(F->Event, CurrentCounter);
652652
IS.CB->CmdBuffer->commit();
653653

654-
if (auto Err = IS.Fence->waitForCompletion(CurrentCounter))
654+
if (auto Err = IS.CompletionFence->waitForCompletion(CurrentCounter))
655655
return Err;
656656

657657
// Check and surface any errors that occurred during execution.
@@ -750,7 +750,7 @@ class MTLDevice : public offloadtest::Device {
750750
return Err;
751751

752752
MTL::TextureDescriptor *TDesc = MTL::TextureDescriptor::texture2DDescriptor(
753-
getMetalPixelFormat(Desc.Format), Desc.Width, Desc.Height,
753+
getMetalPixelFormat(Desc.Fmt), Desc.Width, Desc.Height,
754754
Desc.MipLevels > 1);
755755
TDesc->setMipmapLevelCount(Desc.MipLevels);
756756
TDesc->setStorageMode(getMetalTextureStorageMode(Desc.Location));
@@ -779,7 +779,7 @@ class MTLDevice : public offloadtest::Device {
779779
auto FenceOrErr = createFence("Fence");
780780
if (!FenceOrErr)
781781
return FenceOrErr.takeError();
782-
IS.Fence = std::move(*FenceOrErr);
782+
IS.CompletionFence = std::move(*FenceOrErr);
783783

784784
if (auto Err = createBuffers(P, IS))
785785
return Err;

lib/API/VK/Device.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ class VulkanDevice : public offloadtest::Device {
617617
VkPipelineCache PipelineCache = VK_NULL_HANDLE;
618618
VkPipeline Pipeline = VK_NULL_HANDLE;
619619

620-
std::unique_ptr<Fence> Fence;
620+
std::unique_ptr<offloadtest::Fence> CompletionFence;
621621

622622
// FrameBuffer associated data for offscreen rendering.
623623
VkFramebuffer FrameBuffer = VK_NULL_HANDLE;
@@ -834,7 +834,7 @@ class VulkanDevice : public offloadtest::Device {
834834
VkImageCreateInfo ImageInfo = {};
835835
ImageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
836836
ImageInfo.imageType = VK_IMAGE_TYPE_2D;
837-
ImageInfo.format = getVulkanFormat(Desc.Format);
837+
ImageInfo.format = getVulkanFormat(Desc.Fmt);
838838
ImageInfo.extent = {Desc.Width, Desc.Height, 1};
839839
ImageInfo.mipLevels = Desc.MipLevels;
840840
ImageInfo.arrayLayers = 1;
@@ -885,7 +885,7 @@ class VulkanDevice : public offloadtest::Device {
885885
VkImageViewCreateInfo ViewCi = {};
886886
ViewCi.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
887887
ViewCi.viewType = VK_IMAGE_VIEW_TYPE_2D;
888-
ViewCi.format = getVulkanFormat(Desc.Format);
888+
ViewCi.format = getVulkanFormat(Desc.Fmt);
889889
ViewCi.subresourceRange.baseMipLevel = 0;
890890
ViewCi.subresourceRange.levelCount = 1;
891891
ViewCi.subresourceRange.baseArrayLayer = 0;
@@ -1308,7 +1308,7 @@ class VulkanDevice : public offloadtest::Device {
13081308
return llvm::createStringError(std::errc::device_or_resource_busy,
13091309
"Could not end command buffer.");
13101310

1311-
auto *F = static_cast<VulkanFence *>(IS.Fence.get());
1311+
auto *F = static_cast<VulkanFence *>(IS.CompletionFence.get());
13121312

13131313
VkTimelineSemaphoreSubmitInfo TimelineSubmitInfo = {};
13141314
TimelineSubmitInfo.sType = VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO;
@@ -1328,7 +1328,7 @@ class VulkanDevice : public offloadtest::Device {
13281328
return llvm::createStringError(std::errc::device_or_resource_busy,
13291329
"Failed to submit to queue.");
13301330

1331-
if (auto Err = IS.Fence->waitForCompletion(CurrentCounter))
1331+
if (auto Err = IS.CompletionFence->waitForCompletion(CurrentCounter))
13321332
return Err;
13331333

13341334
vkFreeCommandBuffers(Device, IS.CB->CmdPool, 1, &IS.CB->CmdBuffer);
@@ -1640,7 +1640,7 @@ class VulkanDevice : public offloadtest::Device {
16401640
llvm::Error createRenderPass(InvocationState &IS) {
16411641
std::array<VkAttachmentDescription, 2> Attachments = {};
16421642

1643-
Attachments[0].format = getVulkanFormat(IS.RenderTarget->Desc.Format);
1643+
Attachments[0].format = getVulkanFormat(IS.RenderTarget->Desc.Fmt);
16441644
Attachments[0].samples = VK_SAMPLE_COUNT_1_BIT;
16451645
Attachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
16461646
Attachments[0].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
@@ -1649,7 +1649,7 @@ class VulkanDevice : public offloadtest::Device {
16491649
Attachments[0].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
16501650
Attachments[0].finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
16511651

1652-
Attachments[1].format = getVulkanFormat(IS.DepthStencil->Desc.Format);
1652+
Attachments[1].format = getVulkanFormat(IS.DepthStencil->Desc.Fmt);
16531653
Attachments[1].samples = VK_SAMPLE_COUNT_1_BIT;
16541654
Attachments[1].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
16551655
Attachments[1].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
@@ -2102,7 +2102,7 @@ class VulkanDevice : public offloadtest::Device {
21022102
VkImageLayout OldLayout,
21032103
VkAccessFlags SrcAccessMask,
21042104
VkPipelineStageFlags SrcStageMask) {
2105-
const VkImageAspectFlags AspectMask = isDepthFormat(Tex.Desc.Format)
2105+
const VkImageAspectFlags AspectMask = isDepthFormat(Tex.Desc.Fmt)
21062106
? VK_IMAGE_ASPECT_DEPTH_BIT
21072107
: VK_IMAGE_ASPECT_COLOR_BIT;
21082108

@@ -2512,7 +2512,7 @@ class VulkanDevice : public offloadtest::Device {
25122512
auto FenceOrErr = createFence("Fence");
25132513
if (!FenceOrErr)
25142514
return FenceOrErr.takeError();
2515-
State.Fence = std::move(*FenceOrErr);
2515+
State.CompletionFence = std::move(*FenceOrErr);
25162516
if (auto Err = createShaderModules(P, State))
25172517
return Err;
25182518
llvm::outs() << "Shader module created.\n";

0 commit comments

Comments
 (0)