[dawn][common] Remove TypedInteger consteval overloads See https://dawn-review.googlesource.com/c/dawn/+/310677 (which added the consteval overloads) for an explanation of the problem. With the constEVAL overloads, they can get selected even in non-consteval contexts depending on the argument type. Without them, there's only a constEXPR overload available to select, which is valid anywhere. Note, this requires peppering 'u' suffixes over a ton of code. This is super annoying, but the only alternatives I found were: - Leave as is with the confusing error message. - Have a constEXPR overload for the same thing, that calls DAWN_UNREACHABLE when it's used in a runtime context. This won't catch errors until runtime so would be annoying to iterate in development. Bug: 515794394 Change-Id: Ia71a8891e7729a8ea1ffc506745556f612f93450 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/310678 Reviewed-by: Antonio Maiorano <amaiorano@google.com> Commit-Queue: Kai Ninomiya <kainino@chromium.org>
diff --git a/src/dawn/native/BindGroup.cpp b/src/dawn/native/BindGroup.cpp index 71250f6..b8be76f 100644 --- a/src/dawn/native/BindGroup.cpp +++ b/src/dawn/native/BindGroup.cpp
@@ -617,7 +617,7 @@ MaybeError BindGroupBase::Initialize(const UnpackedPtr<BindGroupDescriptor>& descriptor) { BindGroupLayoutInternalBase* layout = GetLayout(); - for (BindingIndex i{0}; i < layout->GetBindingCount(); ++i) { + for (BindingIndex i{0u}; i < layout->GetBindingCount(); ++i) { // TODO(enga): Shouldn't be needed when bindings are tightly packed. // This is to fill Ref<ObjectBase> holes with nullptrs. new (&mBindingData.bindings[i]) Ref<ObjectBase>(); @@ -746,7 +746,7 @@ void BindGroupBase::DestroyImpl(DestroyReason reason) { if (mLayout != nullptr) { DAWN_CHECK(!IsError()); - for (BindingIndex i{0}; i < GetLayout()->GetBindingCount(); ++i) { + for (BindingIndex i{0u}; i < GetLayout()->GetBindingCount(); ++i) { mBindingData.bindings[i].~Ref<ObjectBase>(); } }
diff --git a/src/dawn/native/BindGroupLayoutInternal.cpp b/src/dawn/native/BindGroupLayoutInternal.cpp index 435ff16..e8ad13c 100644 --- a/src/dawn/native/BindGroupLayoutInternal.cpp +++ b/src/dawn/native/BindGroupLayoutInternal.cpp
@@ -359,7 +359,7 @@ "On entries[%u]: binding number (%u) exceeds the maxBindingsPerBindGroup limit (%u).", i, bindingNumber, kMaxBindingsPerBindGroup); - BindingNumber arraySize{1}; + BindingNumber arraySize{1u}; if (entry->bindingArraySize > 1) { arraySize = BindingNumber(entry->bindingArraySize); @@ -668,7 +668,7 @@ // This is a utility function to help DAWN_ASSERT that the BGL-binding comparator places buffers // first. bool CheckBufferBindingsFirst(ityp::span<BindingIndex, const BindingInfo> bindings) { - BindingIndex lastBufferIndex{0}; + BindingIndex lastBufferIndex{0u}; BindingIndex firstNonBufferIndex = std::numeric_limits<BindingIndex>::max(); for (auto [i, binding] : Enumerate(bindings)) { if (std::holds_alternative<BufferBindingInfo>(binding.bindingLayout)) { @@ -750,7 +750,7 @@ } // Do a prefix sum to store the start offset of each binding type. - BindingIndex sum{0}; + BindingIndex sum{0u}; for (auto [type, count] : Enumerate(counts)) { mBindingTypeStart[type] = sum; sum += count; @@ -888,7 +888,7 @@ if (a->GetBindingCount() != b->GetBindingCount()) { return false; } - for (BindingIndex i{0}; i < a->GetBindingCount(); ++i) { + for (BindingIndex i{0u}; i < a->GetBindingCount(); ++i) { if (a->mBindingInfo[i] != b->mBindingInfo[i]) { return false; }
diff --git a/src/dawn/native/BindingInfo.h b/src/dawn/native/BindingInfo.h index 0d93703..eb339d0 100644 --- a/src/dawn/native/BindingInfo.h +++ b/src/dawn/native/BindingInfo.h
@@ -153,7 +153,7 @@ Ref<SamplerBase> sampler; // Holds the BindingIndex of the single texture with which this sampler is statically paired, if // any. - BindingIndex sampledTextureIndex = BindingIndex(0); + BindingIndex sampledTextureIndex = BindingIndex(0u); // What this sampler will be used for. StaticSamplerUse use = StaticSamplerUse::Freestanding;
diff --git a/src/dawn/native/BlitBufferToDepthStencil.cpp b/src/dawn/native/BlitBufferToDepthStencil.cpp index 074607f..3bc764a 100644 --- a/src/dawn/native/BlitBufferToDepthStencil.cpp +++ b/src/dawn/native/BlitBufferToDepthStencil.cpp
@@ -279,7 +279,7 @@ Ref<BindGroupLayoutBase> bgl; DAWN_TRY_ASSIGN(bgl, pipeline->GetBindGroupLayout(0)); - for (TexelCount z{0}; z < copyExtent.depthOrArrayLayers; ++z) { + for (TexelCount z{0u}; z < copyExtent.depthOrArrayLayers; ++z) { Ref<TextureViewBase> srcView; { TextureViewDescriptor viewDesc = {};
diff --git a/src/dawn/native/BlitBufferToTexture.cpp b/src/dawn/native/BlitBufferToTexture.cpp index b0c41ab..be84352 100644 --- a/src/dawn/native/BlitBufferToTexture.cpp +++ b/src/dawn/native/BlitBufferToTexture.cpp
@@ -391,7 +391,7 @@ } // Must have non-zero copy size. - return copyExtent.width * copyExtent.height * copyExtent.depthOrArrayLayers > TexelCount{0}; + return copyExtent.width * copyExtent.height * copyExtent.depthOrArrayLayers > TexelCount{0u}; } MaybeError BlitBufferToTexture(DeviceBase* device, @@ -447,7 +447,7 @@ break; } - for (TexelCount z{0}; z < copyExtent.depthOrArrayLayers; ++z) { + for (TexelCount z{0u}; z < copyExtent.depthOrArrayLayers; ++z) { Ref<TextureViewBase> dstView; { TextureViewDescriptor viewDesc = {};
diff --git a/src/dawn/native/BlitDepthToDepth.cpp b/src/dawn/native/BlitDepthToDepth.cpp index 84cda9c..412b215 100644 --- a/src/dawn/native/BlitDepthToDepth.cpp +++ b/src/dawn/native/BlitDepthToDepth.cpp
@@ -139,10 +139,10 @@ // sampled as the source instead. ityp::vector<TexelCount, Ref<TextureViewBase>> srcViews; srcViews.reserve(copyExtent.depthOrArrayLayers); - for (TexelCount z = TexelCount{0}; z < copyExtent.depthOrArrayLayers; ++z) { + for (TexelCount z = TexelCount{0u}; z < copyExtent.depthOrArrayLayers; ++z) { TexelCount layer = src.origin.z + z; Ref<TextureViewBase> srcView; - if (layer == TexelCount{0}) { + if (layer == TexelCount{0u}) { // The zero'th slice. We can use the original texture. TextureViewDescriptor viewDesc = {}; viewDesc.aspect = wgpu::TextureAspect::DepthOnly; @@ -192,7 +192,7 @@ } // For each copied layer, blit from the source into the destination. - for (TexelCount z = TexelCount{0}; z < copyExtent.depthOrArrayLayers; ++z) { + for (TexelCount z = TexelCount{0u}; z < copyExtent.depthOrArrayLayers; ++z) { Ref<BindGroupBase> bindGroup; { BindGroupEntry bgEntry = {};
diff --git a/src/dawn/native/BlockInfo.h b/src/dawn/native/BlockInfo.h index 2e5cb17..60680ca 100644 --- a/src/dawn/native/BlockInfo.h +++ b/src/dawn/native/BlockInfo.h
@@ -48,15 +48,15 @@ // Strong type version of Origin3D, which is always in texel space struct TexelOrigin3D { - TexelCount x{0}; - TexelCount y{0}; - TexelCount z{0}; + TexelCount x{0u}; + TexelCount y{0u}; + TexelCount z{0u}; // Construct from input values // NOLINTNEXTLINE: allow implicit constructor - constexpr TexelOrigin3D(TexelCount x = TexelCount{0}, - TexelCount y = TexelCount{0}, - TexelCount z = TexelCount{0}) + constexpr TexelOrigin3D(TexelCount x = TexelCount{0u}, + TexelCount y = TexelCount{0u}, + TexelCount z = TexelCount{0u}) : x(x), y(y), z(z) {} // Implicitly convert from Origin3D as Origin3D is always in texel space @@ -75,15 +75,15 @@ // Stores an origin in block space struct BlockOrigin3D { - BlockCount x{0}; - BlockCount y{0}; - BlockCount z{0}; + BlockCount x{0u}; + BlockCount y{0u}; + BlockCount z{0u}; // Construct from input values // NOLINTNEXTLINE: allow implicit constructor - constexpr BlockOrigin3D(BlockCount x = BlockCount{0}, - BlockCount y = BlockCount{0}, - BlockCount z = BlockCount{0}) + constexpr BlockOrigin3D(BlockCount x = BlockCount{0u}, + BlockCount y = BlockCount{0u}, + BlockCount z = BlockCount{0u}) : x(x), y(y), z(z) {} // Comparison operator @@ -92,9 +92,9 @@ // Strong type version of Extent3D. struct TexelExtent3D { - TexelCount width{0}; - TexelCount height{1}; - TexelCount depthOrArrayLayers{1}; + TexelCount width{0u}; + TexelCount height{1u}; + TexelCount depthOrArrayLayers{1u}; // Default constructor constexpr TexelExtent3D() = default; @@ -102,8 +102,8 @@ // Construct from input values // NOLINTNEXTLINE: allow implicit constructor constexpr TexelExtent3D(TexelCount width, - TexelCount height = TexelCount{1}, - TexelCount depthOrArrayLayers = TexelCount{1}) + TexelCount height = TexelCount{1u}, + TexelCount depthOrArrayLayers = TexelCount{1u}) : width(width), height(height), depthOrArrayLayers(depthOrArrayLayers) {} // Implicitly convert from Extent3D as Extent3D is always in texel space @@ -123,16 +123,16 @@ // Returns true if any extent is zero bool IsEmpty() const { - return width == TexelCount{0} || height == TexelCount{0} || - depthOrArrayLayers == TexelCount{0}; + return width == TexelCount{0u} || height == TexelCount{0u} || + depthOrArrayLayers == TexelCount{0u}; } }; // Stores an extent in block space struct BlockExtent3D { - BlockCount width{0}; - BlockCount height{1}; - BlockCount depthOrArrayLayers{1}; + BlockCount width{0u}; + BlockCount height{1u}; + BlockCount depthOrArrayLayers{1u}; // Default constructor constexpr BlockExtent3D() = default; @@ -140,8 +140,8 @@ // Construct from input values // NOLINTNEXTLINE: allow implicit constructor constexpr BlockExtent3D(BlockCount width, - BlockCount height = BlockCount{1}, - BlockCount depthOrArrayLayers = BlockCount{1}) + BlockCount height = BlockCount{1u}, + BlockCount depthOrArrayLayers = BlockCount{1u}) : width(width), height(height), depthOrArrayLayers(depthOrArrayLayers) {} // Comparison operator @@ -149,8 +149,8 @@ // Returns true if any extent is zero bool IsEmpty() const { - return width == BlockCount{0} || height == BlockCount{0} || - depthOrArrayLayers == BlockCount{0}; + return width == BlockCount{0u} || height == BlockCount{0u} || + depthOrArrayLayers == BlockCount{0u}; } }; @@ -158,8 +158,8 @@ // as TexelCounts, and provides conversion functions between texels, blocks, and bytes. struct TypedTexelBlockInfo { uint32_t byteSize = 0; - TexelCount width{0}; - TexelCount height{0}; + TexelCount width{0u}; + TexelCount height{0u}; // Default constructor constexpr TypedTexelBlockInfo() = default; @@ -193,13 +193,13 @@ // Convert texel height to block height constexpr BlockCount ToBlockHeight(TexelCount value) const { - DAWN_ASSERT(value % height == TexelCount{0}); + DAWN_ASSERT(value % height == TexelCount{0u}); return BlockCount{static_cast<uint64_t>(value / height)}; } // Convert from texel width to block width constexpr BlockCount ToBlockWidth(TexelCount value) const { - DAWN_ASSERT(value % width == TexelCount{0}); + DAWN_ASSERT(value % width == TexelCount{0u}); return BlockCount{static_cast<uint64_t>(value / width)}; }
diff --git a/src/dawn/native/Buffer.h b/src/dawn/native/Buffer.h index 56e753f..2178183 100644 --- a/src/dawn/native/Buffer.h +++ b/src/dawn/native/Buffer.h
@@ -256,7 +256,7 @@ const bool mIsHostMapped = false; bool mIsDataInitialized = false; - Atomic<ExecutionSerial, std::memory_order_relaxed> mLastUsageSerial{ExecutionSerial(0)}; + Atomic<ExecutionSerial, std::memory_order_relaxed> mLastUsageSerial{ExecutionSerial(0u)}; // Once MapAsync() returns a future there is a possible race between MapAsyncEvent completing // and the buffer being unmapped as they can happen on different threads. `mPendingMapMutex`
diff --git a/src/dawn/native/CommandBuffer.cpp b/src/dawn/native/CommandBuffer.cpp index 24bd421..47836fb 100644 --- a/src/dawn/native/CommandBuffer.cpp +++ b/src/dawn/native/CommandBuffer.cpp
@@ -143,8 +143,8 @@ const TexelExtent3D& copySize) { switch (copy.texture->GetDimension()) { case wgpu::TextureDimension::e1D: - DAWN_CHECK(copy.origin.z == TexelCount{0} && - copySize.depthOrArrayLayers == TexelCount{1}); + DAWN_CHECK(copy.origin.z == TexelCount{0u} && + copySize.depthOrArrayLayers == TexelCount{1u}); DAWN_CHECK(copy.mipLevel == 0); return {copy.aspect, {0, 1}, {0, 1}}; case wgpu::TextureDimension::e2D: @@ -337,8 +337,8 @@ const TypedTexelBlockInfo& blockInfo = GetBlockInfo(source); BlockExtent3D copySize = blockInfo.ToBlock(copySize_in); - const bool multiSlice = copySize.depthOrArrayLayers > BlockCount{1}; - const bool multiRow = multiSlice || copySize.height > BlockCount{1}; + const bool multiSlice = copySize.depthOrArrayLayers > BlockCount{1u}; + const bool multiRow = multiSlice || copySize.height > BlockCount{1u}; if (multiSlice && destination.rowsPerImage > copySize.height) { // There are gaps between slices that aren't overwritten
diff --git a/src/dawn/native/CommandBufferStateTracker.cpp b/src/dawn/native/CommandBufferStateTracker.cpp index 6688b0d..3aec007 100644 --- a/src/dawn/native/CommandBufferStateTracker.cpp +++ b/src/dawn/native/CommandBufferStateTracker.cpp
@@ -373,7 +373,7 @@ BindGroupBase* bindGroup = mBindgroups[groupIndex]; BindGroupLayoutInternalBase* bgl = bindGroup->GetLayout(); - for (BindingIndex bindingIndex{0}; bindingIndex < bgl->GetBindingCount(); ++bindingIndex) { + for (BindingIndex bindingIndex{0u}; bindingIndex < bgl->GetBindingCount(); ++bindingIndex) { const BindingInfo& bindingInfo = bgl->GetBindingInfo(bindingIndex); if (!std::holds_alternative<TextureBindingInfo>(bindingInfo.bindingLayout) && !std::holds_alternative<StorageTextureBindingInfo>(bindingInfo.bindingLayout)) {
diff --git a/src/dawn/native/CommandEncoder.cpp b/src/dawn/native/CommandEncoder.cpp index c68db77..9550272 100644 --- a/src/dawn/native/CommandEncoder.cpp +++ b/src/dawn/native/CommandEncoder.cpp
@@ -2021,7 +2021,7 @@ GetDevice()->IsToggleEnabled( Toggle::UseBlitForDepthTextureToTextureCopyToNonzeroSubresource) && copySize->depthOrArrayLayers > 0 && - (dst.mipLevel > 0 || dst.origin.z > TexelCount{0} || + (dst.mipLevel > 0 || dst.origin.z > TexelCount{0u} || copySize->depthOrArrayLayers > 1); // If we're not using a blit, or there are aspects other than depth,
diff --git a/src/dawn/native/CommandValidation.cpp b/src/dawn/native/CommandValidation.cpp index 7fdfac4..e715a47 100644 --- a/src/dawn/native/CommandValidation.cpp +++ b/src/dawn/native/CommandValidation.cpp
@@ -296,7 +296,7 @@ BlockCount blocksPerRow, BlockCount rowsPerImage) { // See ComputeRequiredBytesInCopy overload as this is mostly the same modulo some validation. - if (copySize.depthOrArrayLayers == BlockCount{0}) { + if (copySize.depthOrArrayLayers == BlockCount{0u}) { return 0; } BlockCount widthInBlocks = copySize.width; @@ -307,11 +307,11 @@ uint64_t maxBytesPerImage = std::numeric_limits<uint64_t>::max() / static_cast<uint64_t>(copySize.depthOrArrayLayers); DAWN_CHECK(bytesPerImage <= maxBytesPerImage); - BlockCount blocksToCopy = blocksPerImage * (copySize.depthOrArrayLayers - BlockCount{1}); + BlockCount blocksToCopy = blocksPerImage * (copySize.depthOrArrayLayers - BlockCount{1u}); uint64_t requiredBytesInCopy = blockInfo.ToBytes(blocksToCopy); - if (heightInBlocks > BlockCount{0}) { + if (heightInBlocks > BlockCount{0u}) { BlockCount blocksInLastImage = - blocksPerRow * (heightInBlocks - BlockCount{1}) + blocksInLastRow; + blocksPerRow * (heightInBlocks - BlockCount{1u}) + blocksInLastRow; uint64_t bytesInLastImage = blockInfo.ToBytes(blocksInLastImage); requiredBytesInCopy += bytesInLastImage; }
diff --git a/src/dawn/native/CommandValidation.h b/src/dawn/native/CommandValidation.h index 223f869..95cf503 100644 --- a/src/dawn/native/CommandValidation.h +++ b/src/dawn/native/CommandValidation.h
@@ -110,7 +110,7 @@ // Returns true if [startA, startA + length[ overlaps [startB, startB + length[ template <typename T> bool IsRangeOverlapped(T startA, T startB, T length) { - if (length < T{1}) { + if (length < T{}) { return false; } return RangesOverlap(static_cast<uint64_t>(startA),
diff --git a/src/dawn/native/Commands.h b/src/dawn/native/Commands.h index eaab244..34f5264 100644 --- a/src/dawn/native/Commands.h +++ b/src/dawn/native/Commands.h
@@ -210,8 +210,8 @@ Ref<BufferBase> buffer; uint64_t offset = 0; - BlockCount blocksPerRow = BlockCount(0); - BlockCount rowsPerImage = BlockCount(0); + BlockCount blocksPerRow = BlockCount(0u); + BlockCount rowsPerImage = BlockCount(0u); }; struct TextureCopy { @@ -362,7 +362,7 @@ Ref<QuerySetBase> querySet; QueryIndex firstQuery = kQuerySetIndexUndefinedTyped; - QueryIndex queryCount = QueryIndex(0); + QueryIndex queryCount = QueryIndex(0u); Ref<BufferBase> destination; uint64_t destinationOffset = 0; }; @@ -409,7 +409,7 @@ SetBindGroupCmd(); ~SetBindGroupCmd(); - BindGroupIndex index = BindGroupIndex(0); + BindGroupIndex index = BindGroupIndex(0u); Ref<BindGroupBase> group; uint32_t dynamicOffsetCount = 0; };
diff --git a/src/dawn/native/EventManager.cpp b/src/dawn/native/EventManager.cpp index 5f4fdf8..4178847 100644 --- a/src/dawn/native/EventManager.cpp +++ b/src/dawn/native/EventManager.cpp
@@ -234,7 +234,7 @@ // This call is a no-op if `queueLowestWaitSerials` is empty, otherwise, it ensures that the // lowest serial work is submitted on each queue. - WaitQueueSerials(queueLowestWaitSerials, Nanoseconds(0)); + WaitQueueSerials(queueLowestWaitSerials, Nanoseconds(0u)); // Complete the events that are completable. for (auto& [_, event] : readyEvents) { @@ -330,7 +330,7 @@ }); }; - if (timeout == Nanoseconds(0)) { + if (timeout == Nanoseconds(0u)) { PreProcessWaits(/*waiter=*/nullptr); WaitQueueSerials(queueLowestWaitSerials, timeout); PostProcessWaits(/*shouldComplete=*/true, /*waiter=*/nullptr);
diff --git a/src/dawn/native/ExecutionQueue.cpp b/src/dawn/native/ExecutionQueue.cpp index 036ad77..69c9a7d 100644 --- a/src/dawn/native/ExecutionQueue.cpp +++ b/src/dawn/native/ExecutionQueue.cpp
@@ -107,7 +107,7 @@ } } - if (timeout > Nanoseconds(0)) { + if (timeout > Nanoseconds(0u)) { // We should never need to wait for queue serials after the device has been // Disconnected. DAWN_ASSERT(GetDevice()->GetState() != DeviceBase::State::Disconnected); @@ -127,7 +127,7 @@ DAWN_TRY(EnsureCommandsFlushed(waitSerial)); } - if (timeout > Nanoseconds(0)) { + if (timeout > Nanoseconds(0u)) { // We should never need to wait for queue serials after the device has been // Disconnected. DAWN_ASSERT(GetDevice()->GetState() != DeviceBase::State::Disconnected);
diff --git a/src/dawn/native/Format.cpp b/src/dawn/native/Format.cpp index 9414e66..29f3c98 100644 --- a/src/dawn/native/Format.cpp +++ b/src/dawn/native/Format.cpp
@@ -437,8 +437,8 @@ auto DefineColorFormat = [&](wgpu::TextureFormat fmt, ByteSize byteSize, SampleTypeBit sampleTypes, ComponentCount componentCount, - RenderTargetPixelByteCost rtPixelCost = RenderTargetPixelByteCost(0), - RenderTargetComponentAlignment rtComponentAlign = RenderTargetComponentAlignment(0), + RenderTargetPixelByteCost rtPixelCost = RenderTargetPixelByteCost(0u), + RenderTargetComponentAlignment rtComponentAlign = RenderTargetComponentAlignment(0u), wgpu::TextureFormat baseFormat = wgpu::TextureFormat::Undefined) { Format internalFormat; internalFormat.format = fmt; @@ -450,7 +450,7 @@ internalFormat.unsupportedReason = std::monostate{}; internalFormat.caps = Cap::None; - if (rtPixelCost != RenderTargetPixelByteCost(0)) { + if (rtPixelCost != RenderTargetPixelByteCost(0u)) { internalFormat.renderTargetPixelByteCost = static_cast<uint32_t>(rtPixelCost); internalFormat.renderTargetComponentAlignment = static_cast<uint32_t>(rtComponentAlign); @@ -494,137 +494,140 @@ : SampleTypeBit::UnfilterableFloat; // 1 byte - DefineColorFormat(wgpu::TextureFormat::R8Unorm, ByteSize(1), kAnyFloat, ComponentCount(1), - RenderTargetPixelByteCost(1), RenderTargetComponentAlignment(1)); - DefineColorFormat(wgpu::TextureFormat::R8Snorm, ByteSize(1), kAnyFloat, ComponentCount(1), - RenderTargetPixelByteCost(1), RenderTargetComponentAlignment(1)); - DefineColorFormat(wgpu::TextureFormat::R8Uint, ByteSize(1), SampleTypeBit::Uint, - ComponentCount(1), RenderTargetPixelByteCost(1), - RenderTargetComponentAlignment(1)); - DefineColorFormat(wgpu::TextureFormat::R8Sint, ByteSize(1), SampleTypeBit::Sint, - ComponentCount(1), RenderTargetPixelByteCost(1), - RenderTargetComponentAlignment(1)); + DefineColorFormat(wgpu::TextureFormat::R8Unorm, ByteSize(1u), kAnyFloat, ComponentCount(1u), + RenderTargetPixelByteCost(1u), RenderTargetComponentAlignment(1u)); + DefineColorFormat(wgpu::TextureFormat::R8Snorm, ByteSize(1u), kAnyFloat, ComponentCount(1u), + RenderTargetPixelByteCost(1u), RenderTargetComponentAlignment(1u)); + DefineColorFormat(wgpu::TextureFormat::R8Uint, ByteSize(1u), SampleTypeBit::Uint, + ComponentCount(1u), RenderTargetPixelByteCost(1u), + RenderTargetComponentAlignment(1u)); + DefineColorFormat(wgpu::TextureFormat::R8Sint, ByteSize(1u), SampleTypeBit::Sint, + ComponentCount(1u), RenderTargetPixelByteCost(1u), + RenderTargetComponentAlignment(1u)); // 2 bytes - DefineColorFormat(wgpu::TextureFormat::R16Uint, ByteSize(2), SampleTypeBit::Uint, - ComponentCount(1), RenderTargetPixelByteCost(2), - RenderTargetComponentAlignment(2)); - DefineColorFormat(wgpu::TextureFormat::R16Sint, ByteSize(2), SampleTypeBit::Sint, - ComponentCount(1), RenderTargetPixelByteCost(2), - RenderTargetComponentAlignment(2)); - DefineColorFormat(wgpu::TextureFormat::R16Float, ByteSize(2), kAnyFloat, ComponentCount(1), - RenderTargetPixelByteCost(2), RenderTargetComponentAlignment(2)); - DefineColorFormat(wgpu::TextureFormat::RG8Unorm, ByteSize(2), kAnyFloat, ComponentCount(2), - RenderTargetPixelByteCost(2), RenderTargetComponentAlignment(1)); - DefineColorFormat(wgpu::TextureFormat::RG8Snorm, ByteSize(2), kAnyFloat, ComponentCount(2), - RenderTargetPixelByteCost(2), RenderTargetComponentAlignment(2)); - DefineColorFormat(wgpu::TextureFormat::RG8Uint, ByteSize(2), SampleTypeBit::Uint, - ComponentCount(2), RenderTargetPixelByteCost(2), - RenderTargetComponentAlignment(1)); - DefineColorFormat(wgpu::TextureFormat::RG8Sint, ByteSize(2), SampleTypeBit::Sint, - ComponentCount(2), RenderTargetPixelByteCost(2), - RenderTargetComponentAlignment(1)); + DefineColorFormat(wgpu::TextureFormat::R16Uint, ByteSize(2u), SampleTypeBit::Uint, + ComponentCount(1u), RenderTargetPixelByteCost(2u), + RenderTargetComponentAlignment(2u)); + DefineColorFormat(wgpu::TextureFormat::R16Sint, ByteSize(2u), SampleTypeBit::Sint, + ComponentCount(1u), RenderTargetPixelByteCost(2u), + RenderTargetComponentAlignment(2u)); + DefineColorFormat(wgpu::TextureFormat::R16Float, ByteSize(2u), kAnyFloat, ComponentCount(1u), + RenderTargetPixelByteCost(2u), RenderTargetComponentAlignment(2u)); + DefineColorFormat(wgpu::TextureFormat::RG8Unorm, ByteSize(2u), kAnyFloat, ComponentCount(2u), + RenderTargetPixelByteCost(2u), RenderTargetComponentAlignment(1u)); + DefineColorFormat(wgpu::TextureFormat::RG8Snorm, ByteSize(2u), kAnyFloat, ComponentCount(2u), + RenderTargetPixelByteCost(2u), RenderTargetComponentAlignment(2u)); + DefineColorFormat(wgpu::TextureFormat::RG8Uint, ByteSize(2u), SampleTypeBit::Uint, + ComponentCount(2u), RenderTargetPixelByteCost(2u), + RenderTargetComponentAlignment(1u)); + DefineColorFormat(wgpu::TextureFormat::RG8Sint, ByteSize(2u), SampleTypeBit::Sint, + ComponentCount(2u), RenderTargetPixelByteCost(2u), + RenderTargetComponentAlignment(1u)); // 4 bytes - DefineColorFormat(wgpu::TextureFormat::R32Uint, ByteSize(4), SampleTypeBit::Uint, - ComponentCount(1), RenderTargetPixelByteCost(4), - RenderTargetComponentAlignment(4)); - DefineColorFormat(wgpu::TextureFormat::R32Sint, ByteSize(4), SampleTypeBit::Sint, - ComponentCount(1), RenderTargetPixelByteCost(4), - RenderTargetComponentAlignment(4)); - DefineColorFormat(wgpu::TextureFormat::R32Float, ByteSize(4), sampleTypeFor32BitFloatFormats, - ComponentCount(1), RenderTargetPixelByteCost(4), - RenderTargetComponentAlignment(4)); - DefineColorFormat(wgpu::TextureFormat::RG16Uint, ByteSize(4), SampleTypeBit::Uint, - ComponentCount(2), RenderTargetPixelByteCost(4), - RenderTargetComponentAlignment(2)); - DefineColorFormat(wgpu::TextureFormat::RG16Sint, ByteSize(4), SampleTypeBit::Sint, - ComponentCount(2), RenderTargetPixelByteCost(4), - RenderTargetComponentAlignment(2)); - DefineColorFormat(wgpu::TextureFormat::RG16Float, ByteSize(4), kAnyFloat, ComponentCount(2), - RenderTargetPixelByteCost(4), RenderTargetComponentAlignment(2)); - DefineColorFormat(wgpu::TextureFormat::RGBA8Unorm, ByteSize(4), kAnyFloat, ComponentCount(4), - RenderTargetPixelByteCost(8), RenderTargetComponentAlignment(1)); - DefineColorFormat(wgpu::TextureFormat::RGBA8UnormSrgb, ByteSize(4), kAnyFloat, - ComponentCount(4), RenderTargetPixelByteCost(8), - RenderTargetComponentAlignment(1), wgpu::TextureFormat::RGBA8Unorm); - DefineColorFormat(wgpu::TextureFormat::RGBA8Snorm, ByteSize(4), kAnyFloat, ComponentCount(4), - RenderTargetPixelByteCost(4), RenderTargetComponentAlignment(4)); - DefineColorFormat(wgpu::TextureFormat::RGBA8Uint, ByteSize(4), SampleTypeBit::Uint, - ComponentCount(4), RenderTargetPixelByteCost(4), - RenderTargetComponentAlignment(1)); - DefineColorFormat(wgpu::TextureFormat::RGBA8Sint, ByteSize(4), SampleTypeBit::Sint, - ComponentCount(4), RenderTargetPixelByteCost(4), - RenderTargetComponentAlignment(1)); - DefineColorFormat(wgpu::TextureFormat::BGRA8Unorm, ByteSize(4), kAnyFloat, ComponentCount(4), - RenderTargetPixelByteCost(8), RenderTargetComponentAlignment(1)); - DefineColorFormat(wgpu::TextureFormat::BGRA8UnormSrgb, ByteSize(4), kAnyFloat, - ComponentCount(4), RenderTargetPixelByteCost(8), - RenderTargetComponentAlignment(1), wgpu::TextureFormat::BGRA8Unorm); - DefineColorFormat(wgpu::TextureFormat::RGB10A2Uint, ByteSize(4), SampleTypeBit::Uint, - ComponentCount(4), RenderTargetPixelByteCost(8), - RenderTargetComponentAlignment(4)); - DefineColorFormat(wgpu::TextureFormat::RGB10A2Unorm, ByteSize(4), kAnyFloat, ComponentCount(4), - RenderTargetPixelByteCost(8), RenderTargetComponentAlignment(4)); - DefineColorFormat(wgpu::TextureFormat::RG11B10Ufloat, ByteSize(4), kAnyFloat, ComponentCount(3), - RenderTargetPixelByteCost(8), RenderTargetComponentAlignment(4)); - DefineColorFormat(wgpu::TextureFormat::RGB9E5Ufloat, ByteSize(4), kAnyFloat, ComponentCount(3)); + DefineColorFormat(wgpu::TextureFormat::R32Uint, ByteSize(4u), SampleTypeBit::Uint, + ComponentCount(1u), RenderTargetPixelByteCost(4u), + RenderTargetComponentAlignment(4u)); + DefineColorFormat(wgpu::TextureFormat::R32Sint, ByteSize(4u), SampleTypeBit::Sint, + ComponentCount(1u), RenderTargetPixelByteCost(4u), + RenderTargetComponentAlignment(4u)); + DefineColorFormat(wgpu::TextureFormat::R32Float, ByteSize(4u), sampleTypeFor32BitFloatFormats, + ComponentCount(1u), RenderTargetPixelByteCost(4u), + RenderTargetComponentAlignment(4u)); + DefineColorFormat(wgpu::TextureFormat::RG16Uint, ByteSize(4u), SampleTypeBit::Uint, + ComponentCount(2u), RenderTargetPixelByteCost(4u), + RenderTargetComponentAlignment(2u)); + DefineColorFormat(wgpu::TextureFormat::RG16Sint, ByteSize(4u), SampleTypeBit::Sint, + ComponentCount(2u), RenderTargetPixelByteCost(4u), + RenderTargetComponentAlignment(2u)); + DefineColorFormat(wgpu::TextureFormat::RG16Float, ByteSize(4u), kAnyFloat, ComponentCount(2u), + RenderTargetPixelByteCost(4u), RenderTargetComponentAlignment(2u)); + DefineColorFormat(wgpu::TextureFormat::RGBA8Unorm, ByteSize(4u), kAnyFloat, ComponentCount(4u), + RenderTargetPixelByteCost(8u), RenderTargetComponentAlignment(1u)); + DefineColorFormat(wgpu::TextureFormat::RGBA8UnormSrgb, ByteSize(4u), kAnyFloat, + ComponentCount(4u), RenderTargetPixelByteCost(8u), + RenderTargetComponentAlignment(1u), wgpu::TextureFormat::RGBA8Unorm); + DefineColorFormat(wgpu::TextureFormat::RGBA8Snorm, ByteSize(4u), kAnyFloat, ComponentCount(4u), + RenderTargetPixelByteCost(4u), RenderTargetComponentAlignment(4u)); + DefineColorFormat(wgpu::TextureFormat::RGBA8Uint, ByteSize(4u), SampleTypeBit::Uint, + ComponentCount(4u), RenderTargetPixelByteCost(4u), + RenderTargetComponentAlignment(1u)); + DefineColorFormat(wgpu::TextureFormat::RGBA8Sint, ByteSize(4u), SampleTypeBit::Sint, + ComponentCount(4u), RenderTargetPixelByteCost(4u), + RenderTargetComponentAlignment(1u)); + DefineColorFormat(wgpu::TextureFormat::BGRA8Unorm, ByteSize(4u), kAnyFloat, ComponentCount(4u), + RenderTargetPixelByteCost(8u), RenderTargetComponentAlignment(1u)); + DefineColorFormat(wgpu::TextureFormat::BGRA8UnormSrgb, ByteSize(4u), kAnyFloat, + ComponentCount(4u), RenderTargetPixelByteCost(8u), + RenderTargetComponentAlignment(1u), wgpu::TextureFormat::BGRA8Unorm); + DefineColorFormat(wgpu::TextureFormat::RGB10A2Uint, ByteSize(4u), SampleTypeBit::Uint, + ComponentCount(4u), RenderTargetPixelByteCost(8u), + RenderTargetComponentAlignment(4u)); + DefineColorFormat(wgpu::TextureFormat::RGB10A2Unorm, ByteSize(4u), kAnyFloat, + ComponentCount(4u), RenderTargetPixelByteCost(8u), + RenderTargetComponentAlignment(4u)); + DefineColorFormat(wgpu::TextureFormat::RG11B10Ufloat, ByteSize(4u), kAnyFloat, + ComponentCount(3u), RenderTargetPixelByteCost(8u), + RenderTargetComponentAlignment(4u)); + DefineColorFormat(wgpu::TextureFormat::RGB9E5Ufloat, ByteSize(4u), kAnyFloat, + ComponentCount(3u)); // The OpaqueYCbCrAndroid format acts as if it is a float format, but we later validate when it // is used with a static sampler that the sampler's filteringness matches what the YCbCr info // allows. - DefineColorFormat(wgpu::TextureFormat::OpaqueYCbCrAndroid, ByteSize(1), kAnyFloat, - ComponentCount(0)); + DefineColorFormat(wgpu::TextureFormat::OpaqueYCbCrAndroid, ByteSize(1u), kAnyFloat, + ComponentCount(0u)); // 8 bytes - DefineColorFormat(wgpu::TextureFormat::RG32Uint, ByteSize(8), SampleTypeBit::Uint, - ComponentCount(2), RenderTargetPixelByteCost(8), - RenderTargetComponentAlignment(4)); - DefineColorFormat(wgpu::TextureFormat::RG32Sint, ByteSize(8), SampleTypeBit::Sint, - ComponentCount(2), RenderTargetPixelByteCost(8), - RenderTargetComponentAlignment(4)); - DefineColorFormat(wgpu::TextureFormat::RG32Float, ByteSize(8), sampleTypeFor32BitFloatFormats, - ComponentCount(2), RenderTargetPixelByteCost(8), - RenderTargetComponentAlignment(4)); - DefineColorFormat(wgpu::TextureFormat::RGBA16Uint, ByteSize(8), SampleTypeBit::Uint, - ComponentCount(4), RenderTargetPixelByteCost(8), - RenderTargetComponentAlignment(2)); - DefineColorFormat(wgpu::TextureFormat::RGBA16Sint, ByteSize(8), SampleTypeBit::Sint, - ComponentCount(4), RenderTargetPixelByteCost(8), - RenderTargetComponentAlignment(2)); - DefineColorFormat(wgpu::TextureFormat::RGBA16Float, ByteSize(8), kAnyFloat, ComponentCount(4), - RenderTargetPixelByteCost(8), RenderTargetComponentAlignment(2)); + DefineColorFormat(wgpu::TextureFormat::RG32Uint, ByteSize(8u), SampleTypeBit::Uint, + ComponentCount(2u), RenderTargetPixelByteCost(8u), + RenderTargetComponentAlignment(4u)); + DefineColorFormat(wgpu::TextureFormat::RG32Sint, ByteSize(8u), SampleTypeBit::Sint, + ComponentCount(2u), RenderTargetPixelByteCost(8u), + RenderTargetComponentAlignment(4u)); + DefineColorFormat(wgpu::TextureFormat::RG32Float, ByteSize(8u), sampleTypeFor32BitFloatFormats, + ComponentCount(2u), RenderTargetPixelByteCost(8u), + RenderTargetComponentAlignment(4u)); + DefineColorFormat(wgpu::TextureFormat::RGBA16Uint, ByteSize(8u), SampleTypeBit::Uint, + ComponentCount(4u), RenderTargetPixelByteCost(8u), + RenderTargetComponentAlignment(2u)); + DefineColorFormat(wgpu::TextureFormat::RGBA16Sint, ByteSize(8u), SampleTypeBit::Sint, + ComponentCount(4u), RenderTargetPixelByteCost(8u), + RenderTargetComponentAlignment(2u)); + DefineColorFormat(wgpu::TextureFormat::RGBA16Float, ByteSize(8u), kAnyFloat, ComponentCount(4u), + RenderTargetPixelByteCost(8u), RenderTargetComponentAlignment(2u)); // 16 bytes - DefineColorFormat(wgpu::TextureFormat::RGBA32Uint, ByteSize(16), SampleTypeBit::Uint, - ComponentCount(4), RenderTargetPixelByteCost(16), - RenderTargetComponentAlignment(4)); - DefineColorFormat(wgpu::TextureFormat::RGBA32Sint, ByteSize(16), SampleTypeBit::Sint, - ComponentCount(4), RenderTargetPixelByteCost(16), - RenderTargetComponentAlignment(4)); - DefineColorFormat(wgpu::TextureFormat::RGBA32Float, ByteSize(16), - sampleTypeFor32BitFloatFormats, ComponentCount(4), - RenderTargetPixelByteCost(16), RenderTargetComponentAlignment(4)); + DefineColorFormat(wgpu::TextureFormat::RGBA32Uint, ByteSize(16u), SampleTypeBit::Uint, + ComponentCount(4u), RenderTargetPixelByteCost(16u), + RenderTargetComponentAlignment(4u)); + DefineColorFormat(wgpu::TextureFormat::RGBA32Sint, ByteSize(16u), SampleTypeBit::Sint, + ComponentCount(4u), RenderTargetPixelByteCost(16u), + RenderTargetComponentAlignment(4u)); + DefineColorFormat(wgpu::TextureFormat::RGBA32Float, ByteSize(16u), + sampleTypeFor32BitFloatFormats, ComponentCount(4u), + RenderTargetPixelByteCost(16u), RenderTargetComponentAlignment(4u)); // Norm16 - DefineColorFormat(wgpu::TextureFormat::R16Unorm, ByteSize(2), sampleTypeForNorm16Formats, - ComponentCount(1), RenderTargetPixelByteCost(2), - RenderTargetComponentAlignment(2)); - DefineColorFormat(wgpu::TextureFormat::RG16Unorm, ByteSize(4), sampleTypeForNorm16Formats, - ComponentCount(2), RenderTargetPixelByteCost(4), - RenderTargetComponentAlignment(2)); - DefineColorFormat(wgpu::TextureFormat::RGBA16Unorm, ByteSize(8), sampleTypeForNorm16Formats, - ComponentCount(4), RenderTargetPixelByteCost(8), - RenderTargetComponentAlignment(2)); - DefineColorFormat(wgpu::TextureFormat::R16Snorm, ByteSize(2), sampleTypeForNorm16Formats, - ComponentCount(1), RenderTargetPixelByteCost(2), - RenderTargetComponentAlignment(2)); - DefineColorFormat(wgpu::TextureFormat::RG16Snorm, ByteSize(4), sampleTypeForNorm16Formats, - ComponentCount(2), RenderTargetPixelByteCost(4), - RenderTargetComponentAlignment(2)); - DefineColorFormat(wgpu::TextureFormat::RGBA16Snorm, ByteSize(8), sampleTypeForNorm16Formats, - ComponentCount(4), RenderTargetPixelByteCost(8), - RenderTargetComponentAlignment(2)); + DefineColorFormat(wgpu::TextureFormat::R16Unorm, ByteSize(2u), sampleTypeForNorm16Formats, + ComponentCount(1u), RenderTargetPixelByteCost(2u), + RenderTargetComponentAlignment(2u)); + DefineColorFormat(wgpu::TextureFormat::RG16Unorm, ByteSize(4u), sampleTypeForNorm16Formats, + ComponentCount(2u), RenderTargetPixelByteCost(4u), + RenderTargetComponentAlignment(2u)); + DefineColorFormat(wgpu::TextureFormat::RGBA16Unorm, ByteSize(8u), sampleTypeForNorm16Formats, + ComponentCount(4u), RenderTargetPixelByteCost(8u), + RenderTargetComponentAlignment(2u)); + DefineColorFormat(wgpu::TextureFormat::R16Snorm, ByteSize(2u), sampleTypeForNorm16Formats, + ComponentCount(1u), RenderTargetPixelByteCost(2u), + RenderTargetComponentAlignment(2u)); + DefineColorFormat(wgpu::TextureFormat::RG16Snorm, ByteSize(4u), sampleTypeForNorm16Formats, + ComponentCount(2u), RenderTargetPixelByteCost(4u), + RenderTargetComponentAlignment(2u)); + DefineColorFormat(wgpu::TextureFormat::RGBA16Snorm, ByteSize(8u), sampleTypeForNorm16Formats, + ComponentCount(4u), RenderTargetPixelByteCost(8u), + RenderTargetComponentAlignment(2u)); ComputeFormatCapabilities(device, table); @@ -784,96 +787,96 @@ // using 0 here to mean "unsized" and adding a backend-specific query for the block size. AddDepthFormat(wgpu::TextureFormat::Depth24Plus, 4, Format::supported); AddMultiAspectFormat(wgpu::TextureFormat::Depth24PlusStencil8, TextureSubsampling::Undefined, - Aspect::Depth | Aspect::Stencil, Cap::Renderable | Cap::Multisample, Format::supported, ComponentCount(2), wgpu::TextureFormat::Depth24Plus, wgpu::TextureFormat::Stencil8); + Aspect::Depth | Aspect::Stencil, Cap::Renderable | Cap::Multisample, Format::supported, ComponentCount(2u), wgpu::TextureFormat::Depth24Plus, wgpu::TextureFormat::Stencil8); AddDepthFormat(wgpu::TextureFormat::Depth32Float, 4, Format::supported); UnsupportedReason d32s8UnsupportedReason = device->HasFeature(Feature::Depth32FloatStencil8) ? Format::supported : RequiresFeature{wgpu::FeatureName::Depth32FloatStencil8}; AddMultiAspectFormat(wgpu::TextureFormat::Depth32FloatStencil8, TextureSubsampling::Undefined, - Aspect::Depth | Aspect::Stencil, Cap::Renderable | Cap::Multisample, d32s8UnsupportedReason, ComponentCount(2), wgpu::TextureFormat::Depth32Float, wgpu::TextureFormat::Stencil8); + Aspect::Depth | Aspect::Stencil, Cap::Renderable | Cap::Multisample, d32s8UnsupportedReason, ComponentCount(2u), wgpu::TextureFormat::Depth32Float, wgpu::TextureFormat::Stencil8); // BC compressed formats UnsupportedReason bcFormatUnsupportedReason = device->HasFeature(Feature::TextureCompressionBC) ? Format::supported : RequiresFeature{wgpu::FeatureName::TextureCompressionBC}; - AddBCCompressedFormat(wgpu::TextureFormat::BC1RGBAUnorm, ByteSize(8), Width(4), Height(4), bcFormatUnsupportedReason, ComponentCount(4)); - AddBCCompressedFormat(wgpu::TextureFormat::BC1RGBAUnormSrgb, ByteSize(8), Width(4), Height(4), bcFormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::BC1RGBAUnorm); - AddBCCompressedFormat(wgpu::TextureFormat::BC4RSnorm, ByteSize(8), Width(4), Height(4), bcFormatUnsupportedReason, ComponentCount(1)); - AddBCCompressedFormat(wgpu::TextureFormat::BC4RUnorm, ByteSize(8), Width(4), Height(4), bcFormatUnsupportedReason, ComponentCount(1)); - AddBCCompressedFormat(wgpu::TextureFormat::BC2RGBAUnorm, ByteSize(16), Width(4), Height(4), bcFormatUnsupportedReason, ComponentCount(4)); - AddBCCompressedFormat(wgpu::TextureFormat::BC2RGBAUnormSrgb, ByteSize(16), Width(4), Height(4), bcFormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::BC2RGBAUnorm); - AddBCCompressedFormat(wgpu::TextureFormat::BC3RGBAUnorm, ByteSize(16), Width(4), Height(4), bcFormatUnsupportedReason, ComponentCount(4)); - AddBCCompressedFormat(wgpu::TextureFormat::BC3RGBAUnormSrgb, ByteSize(16), Width(4), Height(4), bcFormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::BC3RGBAUnorm); - AddBCCompressedFormat(wgpu::TextureFormat::BC5RGSnorm, ByteSize(16), Width(4), Height(4), bcFormatUnsupportedReason, ComponentCount(2)); - AddBCCompressedFormat(wgpu::TextureFormat::BC5RGUnorm, ByteSize(16), Width(4), Height(4), bcFormatUnsupportedReason, ComponentCount(2)); - AddBCCompressedFormat(wgpu::TextureFormat::BC6HRGBFloat, ByteSize(16), Width(4), Height(4), bcFormatUnsupportedReason, ComponentCount(3)); - AddBCCompressedFormat(wgpu::TextureFormat::BC6HRGBUfloat, ByteSize(16), Width(4), Height(4), bcFormatUnsupportedReason, ComponentCount(3)); - AddBCCompressedFormat(wgpu::TextureFormat::BC7RGBAUnorm, ByteSize(16), Width(4), Height(4), bcFormatUnsupportedReason, ComponentCount(4)); - AddBCCompressedFormat(wgpu::TextureFormat::BC7RGBAUnormSrgb, ByteSize(16), Width(4), Height(4), bcFormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::BC7RGBAUnorm); + AddBCCompressedFormat(wgpu::TextureFormat::BC1RGBAUnorm, ByteSize(8u), Width(4u), Height(4u), bcFormatUnsupportedReason, ComponentCount(4u)); + AddBCCompressedFormat(wgpu::TextureFormat::BC1RGBAUnormSrgb, ByteSize(8u), Width(4u), Height(4u), bcFormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::BC1RGBAUnorm); + AddBCCompressedFormat(wgpu::TextureFormat::BC4RSnorm, ByteSize(8u), Width(4u), Height(4u), bcFormatUnsupportedReason, ComponentCount(1u)); + AddBCCompressedFormat(wgpu::TextureFormat::BC4RUnorm, ByteSize(8u), Width(4u), Height(4u), bcFormatUnsupportedReason, ComponentCount(1u)); + AddBCCompressedFormat(wgpu::TextureFormat::BC2RGBAUnorm, ByteSize(16u), Width(4u), Height(4u), bcFormatUnsupportedReason, ComponentCount(4u)); + AddBCCompressedFormat(wgpu::TextureFormat::BC2RGBAUnormSrgb, ByteSize(16u), Width(4u), Height(4u), bcFormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::BC2RGBAUnorm); + AddBCCompressedFormat(wgpu::TextureFormat::BC3RGBAUnorm, ByteSize(16u), Width(4u), Height(4u), bcFormatUnsupportedReason, ComponentCount(4u)); + AddBCCompressedFormat(wgpu::TextureFormat::BC3RGBAUnormSrgb, ByteSize(16u), Width(4u), Height(4u), bcFormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::BC3RGBAUnorm); + AddBCCompressedFormat(wgpu::TextureFormat::BC5RGSnorm, ByteSize(16u), Width(4u), Height(4u), bcFormatUnsupportedReason, ComponentCount(2u)); + AddBCCompressedFormat(wgpu::TextureFormat::BC5RGUnorm, ByteSize(16u), Width(4u), Height(4u), bcFormatUnsupportedReason, ComponentCount(2u)); + AddBCCompressedFormat(wgpu::TextureFormat::BC6HRGBFloat, ByteSize(16u), Width(4u), Height(4u), bcFormatUnsupportedReason, ComponentCount(3u)); + AddBCCompressedFormat(wgpu::TextureFormat::BC6HRGBUfloat, ByteSize(16u), Width(4u), Height(4u), bcFormatUnsupportedReason, ComponentCount(3u)); + AddBCCompressedFormat(wgpu::TextureFormat::BC7RGBAUnorm, ByteSize(16u), Width(4u), Height(4u), bcFormatUnsupportedReason, ComponentCount(4u)); + AddBCCompressedFormat(wgpu::TextureFormat::BC7RGBAUnormSrgb, ByteSize(16u), Width(4u), Height(4u), bcFormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::BC7RGBAUnorm); // ETC2/EAC compressed formats UnsupportedReason etc2FormatUnsupportedReason = device->HasFeature(Feature::TextureCompressionETC2) ? Format::supported : RequiresFeature{wgpu::FeatureName::TextureCompressionETC2}; - AddETCCompressedFormat(wgpu::TextureFormat::ETC2RGB8Unorm, ByteSize(8), Width(4), Height(4), etc2FormatUnsupportedReason, ComponentCount(3)); - AddETCCompressedFormat(wgpu::TextureFormat::ETC2RGB8UnormSrgb, ByteSize(8), Width(4), Height(4), etc2FormatUnsupportedReason, ComponentCount(3), wgpu::TextureFormat::ETC2RGB8Unorm); - AddETCCompressedFormat(wgpu::TextureFormat::ETC2RGB8A1Unorm, ByteSize(8), Width(4), Height(4), etc2FormatUnsupportedReason, ComponentCount(4)); - AddETCCompressedFormat(wgpu::TextureFormat::ETC2RGB8A1UnormSrgb, ByteSize(8), Width(4), Height(4), etc2FormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::ETC2RGB8A1Unorm); - AddETCCompressedFormat(wgpu::TextureFormat::ETC2RGBA8Unorm, ByteSize(16), Width(4), Height(4), etc2FormatUnsupportedReason, ComponentCount(4)); - AddETCCompressedFormat(wgpu::TextureFormat::ETC2RGBA8UnormSrgb, ByteSize(16), Width(4), Height(4), etc2FormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::ETC2RGBA8Unorm); - AddETCCompressedFormat(wgpu::TextureFormat::EACR11Unorm, ByteSize(8), Width(4), Height(4), etc2FormatUnsupportedReason, ComponentCount(1)); - AddETCCompressedFormat(wgpu::TextureFormat::EACR11Snorm, ByteSize(8), Width(4), Height(4), etc2FormatUnsupportedReason, ComponentCount(1)); - AddETCCompressedFormat(wgpu::TextureFormat::EACRG11Unorm, ByteSize(16), Width(4), Height(4), etc2FormatUnsupportedReason, ComponentCount(2)); - AddETCCompressedFormat(wgpu::TextureFormat::EACRG11Snorm, ByteSize(16), Width(4), Height(4), etc2FormatUnsupportedReason, ComponentCount(2)); + AddETCCompressedFormat(wgpu::TextureFormat::ETC2RGB8Unorm, ByteSize(8u), Width(4u), Height(4u), etc2FormatUnsupportedReason, ComponentCount(3u)); + AddETCCompressedFormat(wgpu::TextureFormat::ETC2RGB8UnormSrgb, ByteSize(8u), Width(4u), Height(4u), etc2FormatUnsupportedReason, ComponentCount(3u), wgpu::TextureFormat::ETC2RGB8Unorm); + AddETCCompressedFormat(wgpu::TextureFormat::ETC2RGB8A1Unorm, ByteSize(8u), Width(4u), Height(4u), etc2FormatUnsupportedReason, ComponentCount(4u)); + AddETCCompressedFormat(wgpu::TextureFormat::ETC2RGB8A1UnormSrgb, ByteSize(8u), Width(4u), Height(4u), etc2FormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::ETC2RGB8A1Unorm); + AddETCCompressedFormat(wgpu::TextureFormat::ETC2RGBA8Unorm, ByteSize(16u), Width(4u), Height(4u), etc2FormatUnsupportedReason, ComponentCount(4u)); + AddETCCompressedFormat(wgpu::TextureFormat::ETC2RGBA8UnormSrgb, ByteSize(16u), Width(4u), Height(4u), etc2FormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::ETC2RGBA8Unorm); + AddETCCompressedFormat(wgpu::TextureFormat::EACR11Unorm, ByteSize(8u), Width(4u), Height(4u), etc2FormatUnsupportedReason, ComponentCount(1u)); + AddETCCompressedFormat(wgpu::TextureFormat::EACR11Snorm, ByteSize(8u), Width(4u), Height(4u), etc2FormatUnsupportedReason, ComponentCount(1u)); + AddETCCompressedFormat(wgpu::TextureFormat::EACRG11Unorm, ByteSize(16u), Width(4u), Height(4u), etc2FormatUnsupportedReason, ComponentCount(2u)); + AddETCCompressedFormat(wgpu::TextureFormat::EACRG11Snorm, ByteSize(16u), Width(4u), Height(4u), etc2FormatUnsupportedReason, ComponentCount(2u)); // ASTC compressed formats UnsupportedReason astcFormatUnsupportedReason = device->HasFeature(Feature::TextureCompressionASTC) ? Format::supported : RequiresFeature{wgpu::FeatureName::TextureCompressionASTC}; - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC4x4Unorm, ByteSize(16), Width(4), Height(4), astcFormatUnsupportedReason, ComponentCount(4)); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC4x4UnormSrgb, ByteSize(16), Width(4), Height(4), astcFormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::ASTC4x4Unorm); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC5x4Unorm, ByteSize(16), Width(5), Height(4), astcFormatUnsupportedReason, ComponentCount(4)); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC5x4UnormSrgb, ByteSize(16), Width(5), Height(4), astcFormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::ASTC5x4Unorm); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC5x5Unorm, ByteSize(16), Width(5), Height(5), astcFormatUnsupportedReason, ComponentCount(4)); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC5x5UnormSrgb, ByteSize(16), Width(5), Height(5), astcFormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::ASTC5x5Unorm); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC6x5Unorm, ByteSize(16), Width(6), Height(5), astcFormatUnsupportedReason, ComponentCount(4)); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC6x5UnormSrgb, ByteSize(16), Width(6), Height(5), astcFormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::ASTC6x5Unorm); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC6x6Unorm, ByteSize(16), Width(6), Height(6), astcFormatUnsupportedReason, ComponentCount(4)); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC6x6UnormSrgb, ByteSize(16), Width(6), Height(6), astcFormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::ASTC6x6Unorm); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC8x5Unorm, ByteSize(16), Width(8), Height(5), astcFormatUnsupportedReason, ComponentCount(4)); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC8x5UnormSrgb, ByteSize(16), Width(8), Height(5), astcFormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::ASTC8x5Unorm); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC8x6Unorm, ByteSize(16), Width(8), Height(6), astcFormatUnsupportedReason, ComponentCount(4)); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC8x6UnormSrgb, ByteSize(16), Width(8), Height(6), astcFormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::ASTC8x6Unorm); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC8x8Unorm, ByteSize(16), Width(8), Height(8), astcFormatUnsupportedReason, ComponentCount(4)); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC8x8UnormSrgb, ByteSize(16), Width(8), Height(8), astcFormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::ASTC8x8Unorm); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC10x5Unorm, ByteSize(16), Width(10), Height(5), astcFormatUnsupportedReason, ComponentCount(4)); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC10x5UnormSrgb, ByteSize(16), Width(10), Height(5), astcFormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::ASTC10x5Unorm); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC10x6Unorm, ByteSize(16), Width(10), Height(6), astcFormatUnsupportedReason, ComponentCount(4)); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC10x6UnormSrgb, ByteSize(16), Width(10), Height(6), astcFormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::ASTC10x6Unorm); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC10x8Unorm, ByteSize(16), Width(10), Height(8), astcFormatUnsupportedReason, ComponentCount(4)); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC10x8UnormSrgb, ByteSize(16), Width(10), Height(8), astcFormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::ASTC10x8Unorm); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC10x10Unorm, ByteSize(16), Width(10), Height(10), astcFormatUnsupportedReason, ComponentCount(4)); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC10x10UnormSrgb, ByteSize(16), Width(10), Height(10), astcFormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::ASTC10x10Unorm); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC12x10Unorm, ByteSize(16), Width(12), Height(10), astcFormatUnsupportedReason, ComponentCount(4)); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC12x10UnormSrgb, ByteSize(16), Width(12), Height(10), astcFormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::ASTC12x10Unorm); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC12x12Unorm, ByteSize(16), Width(12), Height(12), astcFormatUnsupportedReason, ComponentCount(4)); - AddASTCCompressedFormat(wgpu::TextureFormat::ASTC12x12UnormSrgb, ByteSize(16), Width(12), Height(12), astcFormatUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::ASTC12x12Unorm); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC4x4Unorm, ByteSize(16u), Width(4u), Height(4u), astcFormatUnsupportedReason, ComponentCount(4u)); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC4x4UnormSrgb, ByteSize(16u), Width(4u), Height(4u), astcFormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::ASTC4x4Unorm); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC5x4Unorm, ByteSize(16u), Width(5u), Height(4u), astcFormatUnsupportedReason, ComponentCount(4u)); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC5x4UnormSrgb, ByteSize(16u), Width(5u), Height(4u), astcFormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::ASTC5x4Unorm); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC5x5Unorm, ByteSize(16u), Width(5u), Height(5u), astcFormatUnsupportedReason, ComponentCount(4u)); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC5x5UnormSrgb, ByteSize(16u), Width(5u), Height(5u), astcFormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::ASTC5x5Unorm); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC6x5Unorm, ByteSize(16u), Width(6u), Height(5u), astcFormatUnsupportedReason, ComponentCount(4u)); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC6x5UnormSrgb, ByteSize(16u), Width(6u), Height(5u), astcFormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::ASTC6x5Unorm); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC6x6Unorm, ByteSize(16u), Width(6u), Height(6u), astcFormatUnsupportedReason, ComponentCount(4u)); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC6x6UnormSrgb, ByteSize(16u), Width(6u), Height(6u), astcFormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::ASTC6x6Unorm); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC8x5Unorm, ByteSize(16u), Width(8u), Height(5u), astcFormatUnsupportedReason, ComponentCount(4u)); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC8x5UnormSrgb, ByteSize(16u), Width(8u), Height(5u), astcFormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::ASTC8x5Unorm); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC8x6Unorm, ByteSize(16u), Width(8u), Height(6u), astcFormatUnsupportedReason, ComponentCount(4u)); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC8x6UnormSrgb, ByteSize(16u), Width(8u), Height(6u), astcFormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::ASTC8x6Unorm); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC8x8Unorm, ByteSize(16u), Width(8u), Height(8u), astcFormatUnsupportedReason, ComponentCount(4u)); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC8x8UnormSrgb, ByteSize(16u), Width(8u), Height(8u), astcFormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::ASTC8x8Unorm); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC10x5Unorm, ByteSize(16u), Width(10u), Height(5u), astcFormatUnsupportedReason, ComponentCount(4u)); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC10x5UnormSrgb, ByteSize(16u), Width(10u), Height(5u), astcFormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::ASTC10x5Unorm); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC10x6Unorm, ByteSize(16u), Width(10u), Height(6u), astcFormatUnsupportedReason, ComponentCount(4u)); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC10x6UnormSrgb, ByteSize(16u), Width(10u), Height(6u), astcFormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::ASTC10x6Unorm); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC10x8Unorm, ByteSize(16u), Width(10u), Height(8u), astcFormatUnsupportedReason, ComponentCount(4u)); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC10x8UnormSrgb, ByteSize(16u), Width(10u), Height(8u), astcFormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::ASTC10x8Unorm); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC10x10Unorm, ByteSize(16u), Width(10u), Height(10u), astcFormatUnsupportedReason, ComponentCount(4u)); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC10x10UnormSrgb, ByteSize(16u), Width(10u), Height(10u), astcFormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::ASTC10x10Unorm); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC12x10Unorm, ByteSize(16u), Width(12u), Height(10u), astcFormatUnsupportedReason, ComponentCount(4u)); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC12x10UnormSrgb, ByteSize(16u), Width(12u), Height(10u), astcFormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::ASTC12x10Unorm); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC12x12Unorm, ByteSize(16u), Width(12u), Height(12u), astcFormatUnsupportedReason, ComponentCount(4u)); + AddASTCCompressedFormat(wgpu::TextureFormat::ASTC12x12UnormSrgb, ByteSize(16u), Width(12u), Height(12u), astcFormatUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::ASTC12x12Unorm); // multi-planar formats auto multiPlanarCapabilities = device->HasFeature(Feature::MultiPlanarRenderTargets) ? Cap::Renderable : Cap::None; const UnsupportedReason multiPlanarFormatNv12UnsupportedReason = device->HasFeature(Feature::DawnMultiPlanarFormats) ? Format::supported : RequiresFeature{wgpu::FeatureName::DawnMultiPlanarFormats}; AddMultiAspectFormat(wgpu::TextureFormat::R8BG8Biplanar420Unorm, TextureSubsampling::e420, Aspect::Plane0 | Aspect::Plane1, - multiPlanarCapabilities, multiPlanarFormatNv12UnsupportedReason, ComponentCount(3), wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::RG8Unorm); + multiPlanarCapabilities, multiPlanarFormatNv12UnsupportedReason, ComponentCount(3u), wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::RG8Unorm); const UnsupportedReason multiPlanarFormatNv16UnsupportedReason = device->HasFeature(Feature::MultiPlanarFormatNv16) ? Format::supported : RequiresFeature{wgpu::FeatureName::MultiPlanarFormatNv16}; AddMultiAspectFormat(wgpu::TextureFormat::R8BG8Biplanar422Unorm, TextureSubsampling::e422, Aspect::Plane0 | Aspect::Plane1, - multiPlanarCapabilities, multiPlanarFormatNv16UnsupportedReason, ComponentCount(3), wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::RG8Unorm); + multiPlanarCapabilities, multiPlanarFormatNv16UnsupportedReason, ComponentCount(3u), wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::RG8Unorm); const UnsupportedReason multiPlanarFormatNv24UnsupportedReason = device->HasFeature(Feature::MultiPlanarFormatNv24) ? Format::supported : RequiresFeature{wgpu::FeatureName::MultiPlanarFormatNv24}; AddMultiAspectFormat(wgpu::TextureFormat::R8BG8Biplanar444Unorm, TextureSubsampling::e444, Aspect::Plane0 | Aspect::Plane1, - multiPlanarCapabilities, multiPlanarFormatNv24UnsupportedReason, ComponentCount(3), wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::RG8Unorm); + multiPlanarCapabilities, multiPlanarFormatNv24UnsupportedReason, ComponentCount(3u), wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::RG8Unorm); const UnsupportedReason multiPlanarFormatP010UnsupportedReason = device->HasFeature(Feature::MultiPlanarFormatP010) ? Format::supported : RequiresFeature{wgpu::FeatureName::MultiPlanarFormatP010}; AddMultiAspectFormat(wgpu::TextureFormat::R10X6BG10X6Biplanar420Unorm, TextureSubsampling::e420, Aspect::Plane0 | Aspect::Plane1, - multiPlanarCapabilities, multiPlanarFormatP010UnsupportedReason, ComponentCount(3), wgpu::TextureFormat::R16Unorm, wgpu::TextureFormat::RG16Unorm); + multiPlanarCapabilities, multiPlanarFormatP010UnsupportedReason, ComponentCount(3u), wgpu::TextureFormat::R16Unorm, wgpu::TextureFormat::RG16Unorm); const UnsupportedReason multiPlanarFormatP210UnsupportedReason = device->HasFeature(Feature::MultiPlanarFormatP210) ? Format::supported : RequiresFeature{wgpu::FeatureName::MultiPlanarFormatP210}; AddMultiAspectFormat(wgpu::TextureFormat::R10X6BG10X6Biplanar422Unorm, TextureSubsampling::e422, Aspect::Plane0 | Aspect::Plane1, - multiPlanarCapabilities, multiPlanarFormatP210UnsupportedReason, ComponentCount(3), wgpu::TextureFormat::R16Unorm, wgpu::TextureFormat::RG16Unorm); + multiPlanarCapabilities, multiPlanarFormatP210UnsupportedReason, ComponentCount(3u), wgpu::TextureFormat::R16Unorm, wgpu::TextureFormat::RG16Unorm); const UnsupportedReason multiPlanarFormatP410UnsupportedReason = device->HasFeature(Feature::MultiPlanarFormatP410) ? Format::supported : RequiresFeature{wgpu::FeatureName::MultiPlanarFormatP410}; AddMultiAspectFormat(wgpu::TextureFormat::R10X6BG10X6Biplanar444Unorm, TextureSubsampling::e444, Aspect::Plane0 | Aspect::Plane1, - multiPlanarCapabilities, multiPlanarFormatP410UnsupportedReason, ComponentCount(3), wgpu::TextureFormat::R16Unorm, wgpu::TextureFormat::RG16Unorm); + multiPlanarCapabilities, multiPlanarFormatP410UnsupportedReason, ComponentCount(3u), wgpu::TextureFormat::R16Unorm, wgpu::TextureFormat::RG16Unorm); const UnsupportedReason multiPlanarFormatNv12aUnsupportedReason = device->HasFeature(Feature::MultiPlanarFormatNv12a) ? Format::supported : RequiresFeature{wgpu::FeatureName::MultiPlanarFormatNv12a}; AddMultiAspectFormat(wgpu::TextureFormat::R8BG8A8Triplanar420Unorm, TextureSubsampling::e420, Aspect::Plane0 | Aspect::Plane1 | Aspect::Plane2, - multiPlanarCapabilities, multiPlanarFormatNv12aUnsupportedReason, ComponentCount(4), wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::RG8Unorm, wgpu::TextureFormat::R8Unorm); + multiPlanarCapabilities, multiPlanarFormatNv12aUnsupportedReason, ComponentCount(4u), wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::RG8Unorm, wgpu::TextureFormat::R8Unorm); // clang-format on
diff --git a/src/dawn/native/IndirectDrawMetadata.cpp b/src/dawn/native/IndirectDrawMetadata.cpp index 8073170..f748cef 100644 --- a/src/dawn/native/IndirectDrawMetadata.cpp +++ b/src/dawn/native/IndirectDrawMetadata.cpp
@@ -219,7 +219,7 @@ return; } - IndirectDrawIndex bundleIndirectDrawCount{0}; + IndirectDrawIndex bundleIndirectDrawCount{0u}; for (const auto& [config, validationInfo] : bundle->GetIndirectDrawMetadata().mIndexedIndirectBufferValidationInfo) { auto it = mIndexedIndirectBufferValidationInfo.lower_bound(config);
diff --git a/src/dawn/native/IndirectDrawMetadata.h b/src/dawn/native/IndirectDrawMetadata.h index 77070d4..71d090b 100644 --- a/src/dawn/native/IndirectDrawMetadata.h +++ b/src/dawn/native/IndirectDrawMetadata.h
@@ -68,7 +68,7 @@ }; struct IndirectDraw { - IndirectDrawIndex validatedDrawIndex = IndirectDrawIndex(0); + IndirectDrawIndex validatedDrawIndex = IndirectDrawIndex(0u); uint64_t inputBufferOffset = 0; uint64_t numIndexBufferElements = 0; uint64_t indexBufferOffsetInElements = 0; @@ -219,7 +219,7 @@ std::vector<IndirectMultiDraw> mMultiDraws; - IndirectDrawIndex mNextIndirectDrawIndex{0}; + IndirectDrawIndex mNextIndirectDrawIndex{0u}; ityp::vector<IndirectDrawIndex, ValidatedIndirectDraw> mValidatedIndirectDraws; uint64_t mMaxBatchOffsetRange = 0;
diff --git a/src/dawn/native/IntegerTypes.h b/src/dawn/native/IntegerTypes.h index ac933a3..b910d99 100644 --- a/src/dawn/native/IntegerTypes.h +++ b/src/dawn/native/IntegerTypes.h
@@ -132,14 +132,14 @@ // compare its serial with the currently completed serial. using ExecutionSerial = TypedInteger<struct QueueSerialT, uint64_t>; constexpr ExecutionSerial kMaxExecutionSerial = ExecutionSerial(~uint64_t(0)); -constexpr ExecutionSerial kBeginningOfGPUTime = ExecutionSerial(0); +constexpr ExecutionSerial kBeginningOfGPUTime = ExecutionSerial(0u); // An identifier that indicates which Pipeline a BindGroupLayout is compatible with. Pipelines // created with a default layout will produce BindGroupLayouts with a non-zero compatibility // token, which prevents them (and any BindGroups created with them) from being used with any // other pipelines. using PipelineCompatibilityToken = TypedInteger<struct PipelineCompatibilityTokenT, uint64_t>; -constexpr PipelineCompatibilityToken kExplicitPCT = PipelineCompatibilityToken(0); +constexpr PipelineCompatibilityToken kExplicitPCT = PipelineCompatibilityToken(0u); // An identifier that indicates the index of a RenderPass or ComputePass in a command buffer. // Used to look up additional information related to the pass, such a resource usages.
diff --git a/src/dawn/native/Pipeline.cpp b/src/dawn/native/Pipeline.cpp index d40723e..c372185 100644 --- a/src/dawn/native/Pipeline.cpp +++ b/src/dawn/native/Pipeline.cpp
@@ -350,7 +350,7 @@ DAWN_TRY(GetDevice()->ValidateObject(mLayout.Get())); if (mLayout->UsesResourceTable()) { - DAWN_INVALID_IF(groupIndex >= kMaxBindGroupsTyped - BindGroupIndex(1), + DAWN_INVALID_IF(groupIndex >= kMaxBindGroupsTyped - BindGroupIndex(1u), "Bind group layout index (%u) exceeds or equals the maximum number of bind " "groups (%u) - 1 (one slot reserved for the resource table).", groupIndex, kMaxBindGroups);
diff --git a/src/dawn/native/PipelineLayout.cpp b/src/dawn/native/PipelineLayout.cpp index 8cd442c..bb0c747 100644 --- a/src/dawn/native/PipelineLayout.cpp +++ b/src/dawn/native/PipelineLayout.cpp
@@ -732,7 +732,7 @@ BindGroupIndex PipelineLayoutBase::GroupsInheritUpTo(const PipelineLayoutBase* other) const { DAWN_CHECK(!IsError()); - for (BindGroupIndex i(0); i < kMaxBindGroupsTyped; ++i) { + for (BindGroupIndex i(0u); i < kMaxBindGroupsTyped; ++i) { if (!mMask[i] || mBindGroupLayouts[i].Get() != other->mBindGroupLayouts[i].Get()) { return i; }
diff --git a/src/dawn/native/ProgrammableEncoder.cpp b/src/dawn/native/ProgrammableEncoder.cpp index 4e918b6..fc0dfac 100644 --- a/src/dawn/native/ProgrammableEncoder.cpp +++ b/src/dawn/native/ProgrammableEncoder.cpp
@@ -171,7 +171,7 @@ "in %s.", dynamicOffsets.size(), layout->GetDynamicBufferCount(), layout); - for (BindingIndex i{0}; i < dynamicOffsets.size(); ++i) { + for (BindingIndex i{0u}; i < dynamicOffsets.size(); ++i) { const BindingInfo& bindingInfo = layout->GetBindingInfo(i); // BGL creation sorts bindings such that the dynamic buffer bindings are first.
diff --git a/src/dawn/native/QuerySet.h b/src/dawn/native/QuerySet.h index 6ce5d5d..f036394 100644 --- a/src/dawn/native/QuerySet.h +++ b/src/dawn/native/QuerySet.h
@@ -73,7 +73,7 @@ private: wgpu::QueryType mQueryType = static_cast<wgpu::QueryType>(0); - QueryIndex mQueryCount = QueryIndex(0); + QueryIndex mQueryCount = QueryIndex(0u); enum class QuerySetState { Unavailable, Available, Destroyed }; QuerySetState mState = QuerySetState::Unavailable;
diff --git a/src/dawn/native/RenderPassEncoder.h b/src/dawn/native/RenderPassEncoder.h index a1fabd2..6f8daf9 100644 --- a/src/dawn/native/RenderPassEncoder.h +++ b/src/dawn/native/RenderPassEncoder.h
@@ -112,7 +112,7 @@ // The resources for occlusion query Ref<QuerySetBase> mOcclusionQuerySet; - QueryIndex mCurrentOcclusionQueryIndex = QueryIndex(0); + QueryIndex mCurrentOcclusionQueryIndex = QueryIndex(0u); bool mOcclusionQueryActive = false; // This is the hardcoded value in the WebGPU spec.
diff --git a/src/dawn/native/ResourceTable.h b/src/dawn/native/ResourceTable.h index a6efef5..8a2d25b 100644 --- a/src/dawn/native/ResourceTable.h +++ b/src/dawn/native/ResourceTable.h
@@ -124,13 +124,13 @@ // of the ResourceTable (since the last call to AcquireDirtySlotUpdates or creation of the // ResourceTable). struct MetadataUpdate { - ResourceTableSlot slot{0}; // Slot index to update + ResourceTableSlot slot{0u}; // Slot index to update uint32_t offset = 0; // Byte offset resource array uint32_t data = 0; // tint::ResourceType in the low 16 bits }; struct ResourceDiff { using Resource = std::variant<std::monostate, Ref<TextureViewBase>, Ref<SamplerBase>>; - ResourceTableSlot slot = ResourceTableSlot(0); + ResourceTableSlot slot = ResourceTableSlot(0u); Resource removed; // Resource removed from 'slot', if any Resource added; // Resource added to 'slot', if any }; @@ -154,7 +154,7 @@ // `availableAfter`), so that the slot updates are included in the next batch of updates. void MarkStateDirty(ResourceTableSlot slot); - ResourceTableSlot mAPISize = ResourceTableSlot(0); + ResourceTableSlot mAPISize = ResourceTableSlot(0u); bool mDestroyed = false; // Buffer that contains a WGSL metadata struct of the following shape:
diff --git a/src/dawn/native/ResourceTableDefaultResources.cpp b/src/dawn/native/ResourceTableDefaultResources.cpp index 5beedff..c6dc7be 100644 --- a/src/dawn/native/ResourceTableDefaultResources.cpp +++ b/src/dawn/native/ResourceTableDefaultResources.cpp
@@ -79,7 +79,7 @@ tint::ResourceType::kSampler_non_filtering, tint::ResourceType::kSampler_comparison, }; -constexpr auto kNumDefaultSamplers = ResourceTableSlot{3}; +constexpr auto kNumDefaultSamplers = ResourceTableSlot{3u}; // This helper function is used in ASSERTs to check that the default resources are compatible with // the typeIds that they will be used as defaults for.
diff --git a/src/dawn/native/ShaderModule.cpp b/src/dawn/native/ShaderModule.cpp index fe03b3c..847f584 100644 --- a/src/dawn/native/ShaderModule.cpp +++ b/src/dawn/native/ShaderModule.cpp
@@ -613,7 +613,7 @@ "Binding type in the shader is a binding_array with %u elements but the " "layout only provides %u elements", shaderInfo.arraySize, layoutInfo.arraySize); - DAWN_INVALID_IF(layoutInfo.indexInArray != BindingIndex(0), + DAWN_INVALID_IF(layoutInfo.indexInArray != BindingIndex(0u), "@binding(%u) in the shader is element %u of the layout's binding which is an " "array starting at binding %u.", shaderInfo.binding, layoutInfo.indexInArray, @@ -1153,7 +1153,7 @@ DAWN_INVALID_IF( resource.array_size.has_value() && !deviceInfo.toggles.Has(Toggle::AllowUnsafeAPIs), "Use of binding_array is disabled as an unsafe API."); - DAWN_INVALID_IF(info.arraySize == BindingIndex(0), "binding_array size is 0."); + DAWN_INVALID_IF(info.arraySize == BindingIndex(0u), "binding_array size is 0."); if (DelayedInvalidIf( info.arraySize >= BindingIndex(kMaxBindingsPerBindGroup), "binding_array size (%u) exceeds the maxBindingsPerBindGroup (%u) - 1.",
diff --git a/src/dawn/native/d3d11/CommandBufferD3D11.cpp b/src/dawn/native/d3d11/CommandBufferD3D11.cpp index 8ef993b..feafcc0 100644 --- a/src/dawn/native/d3d11/CommandBufferD3D11.cpp +++ b/src/dawn/native/d3d11/CommandBufferD3D11.cpp
@@ -323,8 +323,8 @@ }; PipelineStateTracker pipelineStateTracker(commandContext); - PassIndex nextComputePassNumber{0}; - PassIndex nextRenderPassNumber{0}; + PassIndex nextComputePassNumber{0u}; + PassIndex nextRenderPassNumber{0u}; Command type; while (mCommands.NextCommandId(&type)) { @@ -666,7 +666,7 @@ PipelineStateTracker* pipelineStateTracker, PassIndex renderPassIndex) { const IndirectDrawMetadata& metadata = GetIndirectDrawMetadata()[renderPassIndex]; - IndirectDrawIndex indirectDrawIndex{0}; + IndirectDrawIndex indirectDrawIndex{0u}; // For the color attachments that the clear_color_with_draw workaround has applied, we can skip // the clear for them.
diff --git a/src/dawn/native/d3d11/PipelineLayoutD3D11.cpp b/src/dawn/native/d3d11/PipelineLayoutD3D11.cpp index 3cb52b3..39a4826 100644 --- a/src/dawn/native/d3d11/PipelineLayoutD3D11.cpp +++ b/src/dawn/native/d3d11/PipelineLayoutD3D11.cpp
@@ -82,7 +82,7 @@ const BindGroupLayoutInternalBase* bgl = GetBindGroupLayout(group); mBindingTableIndexMap[group].resize(bgl->GetBindingCount()); - for (BindingIndex bindingIndex{0}; bindingIndex < bgl->GetBindingCount(); ++bindingIndex) { + for (BindingIndex bindingIndex{0u}; bindingIndex < bgl->GetBindingCount(); ++bindingIndex) { const BindingInfo& bindingInfo = bgl->GetBindingInfo(bindingIndex); mBindingTableIndexMap[group][bindingIndex] = MatchVariant(
diff --git a/src/dawn/native/d3d11/QueueD3D11.cpp b/src/dawn/native/d3d11/QueueD3D11.cpp index af6ed6e..b5c733e 100644 --- a/src/dawn/native/d3d11/QueueD3D11.cpp +++ b/src/dawn/native/d3d11/QueueD3D11.cpp
@@ -802,7 +802,7 @@ bool done; DAWN_TRY_ASSIGN(done, IsQueryCompleted(&commandContext, /*requireFlush=*/false, &(*it))); - if (timeout == Nanoseconds(0)) { + if (timeout == Nanoseconds(0u)) { if (!done) { // Return timed-out immediately without using a timer. return kWaitSerialTimeout;
diff --git a/src/dawn/native/d3d11/TextureD3D11.cpp b/src/dawn/native/d3d11/TextureD3D11.cpp index 689dcdf..30a36cc 100644 --- a/src/dawn/native/d3d11/TextureD3D11.cpp +++ b/src/dawn/native/d3d11/TextureD3D11.cpp
@@ -810,7 +810,7 @@ copyCmd.source.mipLevel = subresources.baseMipLevel; copyCmd.source.aspect = otherAspects; copyCmd.destination.texture = stagingTexture.Get(); - copyCmd.destination.origin = {TexelCount{0}, TexelCount{0}, TexelCount{0}}; + copyCmd.destination.origin = {TexelCount{0u}, TexelCount{0u}, TexelCount{0u}}; copyCmd.destination.mipLevel = 0; copyCmd.destination.aspect = otherAspects; copyCmd.copySize = size; @@ -849,7 +849,7 @@ // Copy to the dest texture from the staging texture. CopyTextureToTextureCmd copyCmd; copyCmd.source.texture = stagingTexture.Get(); - copyCmd.source.origin = {TexelCount{0}, TexelCount{0}, TexelCount{0}}; + copyCmd.source.origin = {TexelCount{0u}, TexelCount{0u}, TexelCount{0u}}; copyCmd.source.mipLevel = 0; copyCmd.source.aspect = GetFormat().aspects; copyCmd.destination.texture = this; @@ -990,7 +990,7 @@ copyCmd.source.mipLevel = subresources.baseMipLevel; copyCmd.source.aspect = subresources.aspects; copyCmd.destination.texture = stagingTexture.Get(); - copyCmd.destination.origin = {TexelCount{0}, TexelCount{0}, TexelCount{0}}; + copyCmd.destination.origin = {TexelCount{0u}, TexelCount{0u}, TexelCount{0u}}; copyCmd.destination.mipLevel = 0; copyCmd.destination.aspect = subresources.aspects; copyCmd.copySize = size;
diff --git a/src/dawn/native/d3d12/BindGroupLayoutD3D12.cpp b/src/dawn/native/d3d12/BindGroupLayoutD3D12.cpp index 7871492..946d3f6 100644 --- a/src/dawn/native/d3d12/BindGroupLayoutD3D12.cpp +++ b/src/dawn/native/d3d12/BindGroupLayoutD3D12.cpp
@@ -112,7 +112,7 @@ mSamplerDescriptorCount(0), mViewSizeIncrement(0), mBindGroupAllocator(MakeFrontendBindGroupAllocator<BindGroup>(4096)) { - for (BindingIndex bindingIndex{0}; bindingIndex < GetBindingCount(); ++bindingIndex) { + for (BindingIndex bindingIndex{0u}; bindingIndex < GetBindingCount(); ++bindingIndex) { const BindingInfo& bindingInfo = GetBindingInfo(bindingIndex); // Skip over bindings that cannot be seen by any shaders as they could cause us to create
diff --git a/src/dawn/native/d3d12/CommandBufferD3D12.cpp b/src/dawn/native/d3d12/CommandBufferD3D12.cpp index 04d1f43..c6152b6 100644 --- a/src/dawn/native/d3d12/CommandBufferD3D12.cpp +++ b/src/dawn/native/d3d12/CommandBufferD3D12.cpp
@@ -696,7 +696,7 @@ // so always try to apply dynamic offsets even if the offsets stay the same. BindGroupLayout* bgl = ToBackend(group->GetLayout()); std::vector<uint32_t> storageBufferDynamicOffsets; - for (BindingIndex bindingIndex{0}; bindingIndex < dynamicOffsets.size(); ++bindingIndex) { + for (BindingIndex bindingIndex{0u}; bindingIndex < dynamicOffsets.size(); ++bindingIndex) { // Note that the order of indices in dynamicOffsets corresponds to the order of // dynamic resource bindings in the BGL by binding number. Because the BGL packs // (uniform and storage) dynamic buffers at the front, and are sorted by binding @@ -994,8 +994,8 @@ ID3D12GraphicsCommandList* commandList = commandContext->GetCommandList(); descriptorHeapState.SetID3D12DescriptorHeaps(commandList); - PassIndex nextComputePassNumber{0}; - PassIndex nextRenderPassNumber{0}; + PassIndex nextComputePassNumber{0u}; + PassIndex nextRenderPassNumber{0u}; Command type; while (mCommands.NextCommandId(&type)) { @@ -1211,18 +1211,18 @@ &sourceRegion); } } else { - const TexelExtent3D copyExtentOneSlice = {copy->copySize.width, - copy->copySize.height, TexelCount{1}}; + const TexelExtent3D copyExtentOneSlice = { + copy->copySize.width, copy->copySize.height, TexelCount{1u}}; for (Aspect aspect : IterateEnumMask(srcRange.aspects)) { - for (TexelCount z{0}; z < copy->copySize.depthOrArrayLayers; ++z) { + for (TexelCount z{0u}; z < copy->copySize.depthOrArrayLayers; ++z) { uint32_t sourceLayer = 0; - TexelCount sourceZ{0}; + TexelCount sourceZ{0u}; switch (source->GetDimension()) { case wgpu::TextureDimension::Undefined: DAWN_UNREACHABLE(); case wgpu::TextureDimension::e1D: - DAWN_ASSERT(copy->source.origin.z == TexelCount{0}); + DAWN_ASSERT(copy->source.origin.z == TexelCount{0u}); break; case wgpu::TextureDimension::e2D: sourceLayer = @@ -1234,12 +1234,12 @@ } uint32_t destinationLayer = 0; - TexelCount destinationZ{0}; + TexelCount destinationZ{0u}; switch (destination->GetDimension()) { case wgpu::TextureDimension::Undefined: DAWN_UNREACHABLE(); case wgpu::TextureDimension::e1D: - DAWN_ASSERT(copy->destination.origin.z == TexelCount{0}); + DAWN_ASSERT(copy->destination.origin.z == TexelCount{0u}); break; case wgpu::TextureDimension::e2D: destinationLayer = @@ -1748,7 +1748,7 @@ const bool useRenderPass = device->IsToggleEnabled(Toggle::UseD3D12RenderPass); const IndirectDrawMetadata& metadata = GetIndirectDrawMetadata()[renderPassIndex]; - IndirectDrawIndex indirectDrawIndex{0}; + IndirectDrawIndex indirectDrawIndex{0u}; // renderPassBuilder must be scoped to RecordRenderPass because any underlying // D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS structs must remain
diff --git a/src/dawn/native/d3d12/GPUDescriptorHeapAllocationD3D12.h b/src/dawn/native/d3d12/GPUDescriptorHeapAllocationD3D12.h index 371a0a7..ec6dbba 100644 --- a/src/dawn/native/d3d12/GPUDescriptorHeapAllocationD3D12.h +++ b/src/dawn/native/d3d12/GPUDescriptorHeapAllocationD3D12.h
@@ -48,8 +48,8 @@ private: D3D12_GPU_DESCRIPTOR_HANDLE mBaseDescriptor = {0}; - ExecutionSerial mLastUsageSerial = ExecutionSerial(0); - HeapVersionID mHeapSerial = HeapVersionID(0); + ExecutionSerial mLastUsageSerial = ExecutionSerial(0u); + HeapVersionID mHeapSerial = HeapVersionID(0u); }; } // namespace dawn::native::d3d12
diff --git a/src/dawn/native/d3d12/PageableD3D12.h b/src/dawn/native/d3d12/PageableD3D12.h index 76b7aa8..5ad7e42 100644 --- a/src/dawn/native/d3d12/PageableD3D12.h +++ b/src/dawn/native/d3d12/PageableD3D12.h
@@ -76,14 +76,14 @@ private: // mLastUsage denotes the last time this pageable was recorded for use. - ExecutionSerial mLastUsage = ExecutionSerial(0); + ExecutionSerial mLastUsage = ExecutionSerial(0u); // mLastSubmission denotes the last time this pageable was submitted to the GPU. Note that // although this variable often contains the same value as mLastUsage, it can differ in some // situations. When some asynchronous APIs (like WriteBuffer) are called, mLastUsage is // updated upon the call, but the backend operation is deferred until the next submission // to the GPU. This makes mLastSubmission unique from mLastUsage, and allows us to // accurately identify when a pageable can be evicted. - ExecutionSerial mLastSubmission = ExecutionSerial(0); + ExecutionSerial mLastSubmission = ExecutionSerial(0u); MemorySegment mMemorySegment; uint32_t mResidencyLockRefCount = 0; uint64_t mSize = 0;
diff --git a/src/dawn/native/d3d12/QueueD3D12.cpp b/src/dawn/native/d3d12/QueueD3D12.cpp index 3c344d7..f1a384e 100644 --- a/src/dawn/native/d3d12/QueueD3D12.cpp +++ b/src/dawn/native/d3d12/QueueD3D12.cpp
@@ -186,7 +186,7 @@ } if (completedSerial <= GetCompletedCommandSerial()) { - return ExecutionSerial(0); + return ExecutionSerial(0u); } DAWN_TRY(RecycleSystemEventReceivers(completedSerial));
diff --git a/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.h b/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.h index 0c2b96c..446dbc8 100644 --- a/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.h +++ b/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.h
@@ -117,7 +117,7 @@ // The serial value of 0 means the shader-visible heaps have not been allocated. // This value is never returned in the GPUDescriptorHeapAllocation after // AllocateGPUDescriptors() is called. - HeapVersionID mHeapSerial = HeapVersionID(0); + HeapVersionID mHeapSerial = HeapVersionID(0u); uint32_t mSizeIncrement;
diff --git a/src/dawn/native/d3d12/SwapChainD3D12.h b/src/dawn/native/d3d12/SwapChainD3D12.h index 8c79e3f..249a45e 100644 --- a/src/dawn/native/d3d12/SwapChainD3D12.h +++ b/src/dawn/native/d3d12/SwapChainD3D12.h
@@ -68,7 +68,7 @@ struct Buffer { ComPtr<ID3D12Resource> resource; // Pretend all the buffers were last used at the beginning of time. - ExecutionSerial lastUsed = ExecutionSerial(0); + ExecutionSerial lastUsed = ExecutionSerial(0u); // SwapChain textures are as if in the COMMON state when first queried. // We need to keep the state and not always assume COMMON because when a swapchain is // reused, the underlying resource might have been transitioned when wrapped in the
diff --git a/src/dawn/native/d3d12/TextureCopySplitter.cpp b/src/dawn/native/d3d12/TextureCopySplitter.cpp index 2f033b8..2991711 100644 --- a/src/dawn/native/d3d12/TextureCopySplitter.cpp +++ b/src/dawn/native/d3d12/TextureCopySplitter.cpp
@@ -37,18 +37,18 @@ BlockOrigin3D ComputeBlockOffsets(const TypedTexelBlockInfo& blockInfo, uint32_t offset, BlockCount blocksPerRow) { - DAWN_ASSERT(blocksPerRow != BlockCount{0}); + DAWN_ASSERT(blocksPerRow != BlockCount{0u}); BlockCount offsetInBlocks = blockInfo.BytesToBlocks(offset); BlockCount blockOffsetX = offsetInBlocks % blocksPerRow; BlockCount blockOffsetY = offsetInBlocks / blocksPerRow; - return {blockOffsetX, blockOffsetY, BlockCount{0}}; + return {blockOffsetX, blockOffsetY, BlockCount{0u}}; } uint64_t OffsetToFirstCopiedTexel(const TypedTexelBlockInfo& blockInfo, BlockCount blocksPerRow, uint64_t alignedOffset, BlockOrigin3D bufferOffset) { - DAWN_ASSERT(bufferOffset.z == BlockCount{0}); + DAWN_ASSERT(bufferOffset.z == BlockCount{0u}); uint64_t offset = alignedOffset + blockInfo.ToBytes(bufferOffset.x + blocksPerRow * bufferOffset.y); return offset; @@ -158,7 +158,7 @@ // Copy 0: copy copySize0.height - 1 rows TextureCopySubresource::CopyInfo& copy0 = copy.copies[i]; - copy0.copySize.height = copySize.height - BlockCount{1}; + copy0.copySize.height = copySize.height - BlockCount{1u}; copy0.bufferSize.height = rowsPerImage; // Copy 1: move down 2 rows and copy the last row on image 0, and expand to all depth slices @@ -166,12 +166,12 @@ TextureCopySubresource::CopyInfo* copy1 = copy.AddCopy(); *copy1 = copy0; copy1->alignedOffset = copy1->alignedOffset + 2 * blockInfo.ToBytes(blocksPerRow); - copy1->textureOffset.y += copySize.height - BlockCount{1}; + copy1->textureOffset.y += copySize.height - BlockCount{1u}; // Offset two rows from the copy height for bufferOffset1 (See the figure above): // - one for the row we advanced in the buffer: row (N + 4). // - one for the last row we want to copy: row (N + 3) itself. - copy1->bufferOffset.y = copySize.height - BlockCount{2}; - copy1->copySize.height = BlockCount{1}; + copy1->bufferOffset.y = copySize.height - BlockCount{2u}; + copy1->copySize.height = BlockCount{1u}; copy1->copySize.depthOrArrayLayers--; copy1->bufferSize.depthOrArrayLayers--; @@ -180,9 +180,9 @@ OffsetToFirstCopiedTexel(blockInfo, blocksPerRow, copy0.alignedOffset, copy0.bufferOffset); uint64_t offsetForLastRowOfLastImage = offsetForCopy0 + - blockInfo.ToBytes( - blocksPerRow * - (copy0.copySize.height + rowsPerImage * (copySize.depthOrArrayLayers - BlockCount{1}))); + blockInfo.ToBytes(blocksPerRow * + (copy0.copySize.height + + rowsPerImage * (copySize.depthOrArrayLayers - BlockCount{1u}))); uint64_t alignedOffsetForLastRowOfLastImage = AlignDownForDataPlacement(offsetForLastRowOfLastImage); @@ -194,14 +194,14 @@ TextureCopySubresource::CopyInfo* copy2 = copy.AddCopy(); copy2->alignedOffset = alignedOffsetForLastRowOfLastImage; copy2->textureOffset = copy1->textureOffset; - copy2->textureOffset.z = origin.z + copySize.depthOrArrayLayers - BlockCount{1}; + copy2->textureOffset.z = origin.z + copySize.depthOrArrayLayers - BlockCount{1u}; copy2->copySize = copy1->copySize; - copy2->copySize.depthOrArrayLayers = BlockCount{1}; + copy2->copySize.depthOrArrayLayers = BlockCount{1u}; copy2->bufferOffset = blockOffsetForLastRowOfLastImage; copy2->bufferSize.width = copy1->bufferSize.width; - DAWN_ASSERT(copy2->copySize.height == BlockCount{1}); + DAWN_ASSERT(copy2->copySize.height == BlockCount{1u}); copy2->bufferSize.height = copy2->bufferOffset.y + copy2->copySize.height; - copy2->bufferSize.depthOrArrayLayers = BlockCount{1}; + copy2->bufferSize.depthOrArrayLayers = BlockCount{1u}; } void Recompute3DTextureCopyRegionWithEmptyFirstRowAndOddCopyHeight( @@ -222,26 +222,26 @@ // Copy 0: copy the first depth slice (image 0) TextureCopySubresource::CopyInfo& copy0 = copy.copies[i]; - copy0.copySize.depthOrArrayLayers = BlockCount{1}; - const BlockCount kBufferDepth0 = BlockCount{1}; + copy0.copySize.depthOrArrayLayers = BlockCount{1u}; + const BlockCount kBufferDepth0 = BlockCount{1u}; copy0.bufferSize.depthOrArrayLayers = kBufferDepth0; // Copy 1: copy the rest depth slices in one shot TextureCopySubresource::CopyInfo* copy1 = copy.AddCopy(); *copy1 = copy0; - DAWN_ASSERT(copySize.height % BlockCount{2} == BlockCount{1}); - copy1->alignedOffset += blockInfo.ToBytes((copySize.height + BlockCount{1}) * blocksPerRow); + DAWN_ASSERT(copySize.height % BlockCount{2u} == BlockCount{1u}); + copy1->alignedOffset += blockInfo.ToBytes((copySize.height + BlockCount{1u}) * blocksPerRow); DAWN_ASSERT(copy1->alignedOffset % D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT == 0); // textureOffset1.z should add one because the first slice has already been copied in copy0. copy1->textureOffset.z++; // bufferOffset1.y should be 0 because we skipped the first depth slice and there is no empty // row in this copy region. - copy1->bufferOffset.y = BlockCount{0}; + copy1->bufferOffset.y = BlockCount{0u}; copy1->copySize.height = copySize.height; - copy1->copySize.depthOrArrayLayers = copySize.depthOrArrayLayers - BlockCount{1}; + copy1->copySize.depthOrArrayLayers = copySize.depthOrArrayLayers - BlockCount{1u}; copy1->bufferSize.height = copySize.height; - copy1->bufferSize.depthOrArrayLayers = copySize.depthOrArrayLayers - BlockCount{1}; + copy1->bufferSize.depthOrArrayLayers = copySize.depthOrArrayLayers - BlockCount{1u}; } TextureCopySubresource Compute2DTextureCopySubresourceAligned(BlockOrigin3D origin, @@ -293,8 +293,8 @@ BlockOrigin3D blockOffset = ComputeBlockOffsets(blockInfo, static_cast<uint32_t>(offset - alignedOffset), blocksPerRow); - DAWN_ASSERT(blockOffset.y <= BlockCount{1}); - DAWN_ASSERT(blockOffset.z == BlockCount{0}); + DAWN_ASSERT(blockOffset.y <= BlockCount{1u}); + DAWN_ASSERT(blockOffset.z == BlockCount{0u}); BlockCount copyBlocksPerRowPitch = copySize.width; BlockCount blockOffsetInRowPitch = blockOffset.x; @@ -385,8 +385,8 @@ const BlockOrigin3D blockOffsetForCopy1 = ComputeBlockOffsets( blockInfo, static_cast<uint32_t>(offsetForCopy1 - alignedOffsetForCopy1), blocksPerRow); - DAWN_ASSERT(blockOffsetForCopy1.y <= BlockCount{1}); - DAWN_ASSERT(blockOffsetForCopy1.z == BlockCount{0}); + DAWN_ASSERT(blockOffsetForCopy1.y <= BlockCount{1u}); + DAWN_ASSERT(blockOffsetForCopy1.z == BlockCount{0u}); const BlockOrigin3D textureOffset1 = {origin.x + copySize0.width, origin.y, origin.z}; @@ -428,11 +428,11 @@ // |++++++++++++++++++++++| | | | // |<-----CopyWidth------>| |----------| // - copyInfo->textureOffset = {origin.x, origin.y, BlockCount{0}}; + copyInfo->textureOffset = {origin.x, origin.y, BlockCount{0u}}; copyInfo->bufferOffset = {}; // 0,0,0 - copyInfo->copySize = {copySize.width, copySize.height, BlockCount{1}}; + copyInfo->copySize = {copySize.width, copySize.height, BlockCount{1u}}; copyInfo->alignedOffset = offset; - copyInfo->bufferSize = {copySize.width, copySize.height, BlockCount{1}}; + copyInfo->bufferSize = {copySize.width, copySize.height, BlockCount{1u}}; return copy; } @@ -462,7 +462,7 @@ DAWN_ASSERT(copySubresource.count <= 2); // If copySize.depthOrArrayLayers is 1, we can return copySubresource. Because we don't need to // extend the copy region(s) to other depth slice(s). - if (copySize.depthOrArrayLayers == BlockCount{1}) { + if (copySize.depthOrArrayLayers == BlockCount{1u}) { return copySubresource; } @@ -473,7 +473,7 @@ for (uint32_t i = 0; i < originalCopyCount; ++i) { // There can be one empty row at most in a copy region. BlockCount bufferHeight = copySubresource.copies[i].bufferSize.height; - DAWN_ASSERT(bufferHeight <= rowsPerImage + BlockCount{1}); + DAWN_ASSERT(bufferHeight <= rowsPerImage + BlockCount{1u}); if (bufferHeight == rowsPerImage) { // If the copy region's bufferHeight equals to rowsPerImage, we can use this @@ -528,12 +528,12 @@ BlockCount blocksPerRow, BlockCount rowsPerImage) { TextureCopySubresource copy; - BlockOrigin3D bufferOffset{BlockCount{0}, BlockCount{0}, BlockCount{0}}; + BlockOrigin3D bufferOffset{BlockCount{0u}, BlockCount{0u}, BlockCount{0u}}; // You can visualize the data in the buffer (bufferLocation) like the inline comments. // * copy data is visualized as '+'. - const BlockCount depthInCopy1 = copySize.depthOrArrayLayers - BlockCount{1}; - if (depthInCopy1 > BlockCount{0}) { + const BlockCount depthInCopy1 = copySize.depthOrArrayLayers - BlockCount{1u}; + if (depthInCopy1 > BlockCount{0u}) { // `bufferLocation` in the 1st copy (first `depthInCopy1` images, optional): // // bufferOffset(0, 0, 0) @@ -581,8 +581,8 @@ // ^ // End of all buffer data // - DAWN_ASSERT(copySize.depthOrArrayLayers >= BlockCount{1}); - constexpr BlockCount depthInCopy2{1}; + DAWN_ASSERT(copySize.depthOrArrayLayers >= BlockCount{1u}); + constexpr BlockCount depthInCopy2{1u}; const BlockCount rowsPerImageInTexels2 = copySize.height; auto* copyInfo2 = copy.AddCopy(); @@ -654,15 +654,15 @@ // and reuse it for all the layers. BlockExtent3D copyOneLayerSize = copySize; BlockOrigin3D copyFirstLayerOrigin = origin; - copyOneLayerSize.depthOrArrayLayers = BlockCount{1}; - copyFirstLayerOrigin.z = BlockCount{0}; + copyOneLayerSize.depthOrArrayLayers = BlockCount{1u}; + copyFirstLayerOrigin.z = BlockCount{0u}; copies.copySubresources[0] = Compute2DTextureCopySubresourceAligned( copyFirstLayerOrigin, copyOneLayerSize, blockInfo, offset, blocksPerRow); // When the copy only refers one texture 2D array layer, // copies.copySubresources[1] will never be used so we can safely early return here. - if (copySize.depthOrArrayLayers == BlockCount{1}) { + if (copySize.depthOrArrayLayers == BlockCount{1u}) { return copies; }
diff --git a/src/dawn/native/d3d12/TextureD3D12.cpp b/src/dawn/native/d3d12/TextureD3D12.cpp index 9a14370..fbfdb24 100644 --- a/src/dawn/native/d3d12/TextureD3D12.cpp +++ b/src/dawn/native/d3d12/TextureD3D12.cpp
@@ -933,7 +933,8 @@ TextureCopy textureCopy; textureCopy.texture = this; - textureCopy.origin = {TexelCount{0}, TexelCount{0}, TexelCount{layer}}; + textureCopy.origin = {TexelCount{0u}, TexelCount{0u}, + TexelCount{layer}}; textureCopy.mipLevel = level; textureCopy.aspect = aspect; RecordBufferTextureCopyWithBufferHandle(
diff --git a/src/dawn/native/d3d12/UtilsD3D12.cpp b/src/dawn/native/d3d12/UtilsD3D12.cpp index d3fa24f..704b53e 100644 --- a/src/dawn/native/d3d12/UtilsD3D12.cpp +++ b/src/dawn/native/d3d12/UtilsD3D12.cpp
@@ -66,12 +66,12 @@ // Compute (block) size for the first images except the last. BlockCount allButLastImage = - blocksPerRow * rowsPerImage * (copySize.depthOrArrayLayers - BlockCount{1}); + blocksPerRow * rowsPerImage * (copySize.depthOrArrayLayers - BlockCount{1u}); // Compute (block) size of the last image as D3D12 does, which includes the size of whole last // row BlockCount lastRow = copySize.width; DAWN_ASSERT(rowsPerImage > copySize.height); - BlockCount lastImageByD3D12 = blocksPerRow * (rowsPerImage - BlockCount{1}) + lastRow; + BlockCount lastImageByD3D12 = blocksPerRow * (rowsPerImage - BlockCount{1u}) + lastRow; // Compute total (block) size as D3D12 does BlockCount requiredCopySizeByD3D12 = allButLastImage + lastImageByD3D12; return blockInfo.ToBytes(requiredCopySizeByD3D12); @@ -88,7 +88,7 @@ const BlockExtent3D& copySize) { TextureBase* texture = textureCopy.texture.Get(); if (texture->GetDimension() != wgpu::TextureDimension::e3D || - copySize.depthOrArrayLayers <= BlockCount{1} || + copySize.depthOrArrayLayers <= BlockCount{1u} || bufferCopy.rowsPerImage <= copySize.height) { return false; } @@ -329,7 +329,7 @@ origin, copySize, blockInfo, offset, blocksPerRow, useRelaxedRowPitchAndOffset); RecordBufferTextureCopyFromSplits( direction, commandList, copySubresource, bufferResource, 0, blocksPerRow, blockInfo, - texture, textureCopy.mipLevel, BlockCount{0}, textureCopy.aspect); + texture, textureCopy.mipLevel, BlockCount{0u}, textureCopy.aspect); break; } @@ -355,7 +355,7 @@ rowsPerImage, useRelaxedRowPitchAndOffset); RecordBufferTextureCopyFromSplits( direction, commandList, copySubresource, bufferResource, 0, blocksPerRow, blockInfo, - texture, textureCopy.mipLevel, BlockCount{0}, textureCopy.aspect); + texture, textureCopy.mipLevel, BlockCount{0u}, textureCopy.aspect); break; } } @@ -377,22 +377,22 @@ // - The second copy will copy the last depth image, skipping the padding rows between // the second-to-last and last image. BlockExtent3D extentForAllButTheLastImage = copySize; - extentForAllButTheLastImage.depthOrArrayLayers -= BlockCount{1}; + extentForAllButTheLastImage.depthOrArrayLayers -= BlockCount{1u}; RecordBufferTextureCopyWithBufferHandle( direction, commandList, bufferResource, bufferCopy.offset, bufferCopy.blocksPerRow, bufferCopy.rowsPerImage, textureCopy, extentForAllButTheLastImage); BlockExtent3D extentForTheLastImage = copySize; - extentForTheLastImage.depthOrArrayLayers = BlockCount{1}; + extentForTheLastImage.depthOrArrayLayers = BlockCount{1u}; TextureCopy textureCopyForTheLastImage = textureCopy; textureCopyForTheLastImage.origin.z += - blockInfo.ToTexelDepth(copySize.depthOrArrayLayers) - TexelCount{1}; + blockInfo.ToTexelDepth(copySize.depthOrArrayLayers) - TexelCount{1u}; // We offset the copy so that we skip the padding rows. This way the footprint Height // will be computed without this padding. uint64_t copiedBytes = blockInfo.ToBytes(bufferCopy.blocksPerRow * bufferCopy.rowsPerImage * - (copySize.depthOrArrayLayers - BlockCount{1})); + (copySize.depthOrArrayLayers - BlockCount{1u})); RecordBufferTextureCopyWithBufferHandle(direction, commandList, bufferResource, bufferCopy.offset + copiedBytes, bufferCopy.blocksPerRow, bufferCopy.rowsPerImage,
diff --git a/src/dawn/native/metal/BindGroupLayoutMTL.mm b/src/dawn/native/metal/BindGroupLayoutMTL.mm index e26cd17..f6bb201 100644 --- a/src/dawn/native/metal/BindGroupLayoutMTL.mm +++ b/src/dawn/native/metal/BindGroupLayoutMTL.mm
@@ -55,7 +55,7 @@ // Pool to free MTLArgumentDescriptor and NSArray. @autoreleasepool { std::vector<MTLArgumentDescriptor*> descriptors; - for (BindingIndex bindingIndex{0}; bindingIndex < GetBindingCount(); ++bindingIndex) { + for (BindingIndex bindingIndex{0u}; bindingIndex < GetBindingCount(); ++bindingIndex) { auto& bindingInfo = GetBindingInfo(bindingIndex); MTLArgumentDescriptor* desc = [MTLArgumentDescriptor argumentDescriptor];
diff --git a/src/dawn/native/metal/CommandBufferMTL.mm b/src/dawn/native/metal/CommandBufferMTL.mm index cb0fed4..32776dd 100644 --- a/src/dawn/native/metal/CommandBufferMTL.mm +++ b/src/dawn/native/metal/CommandBufferMTL.mm
@@ -1043,9 +1043,9 @@ } case wgpu::TextureDimension::e2D: { const MTLOrigin textureOrigin = ToMTLOrigin( - {copyInfo.textureOrigin.x, copyInfo.textureOrigin.y, TexelCount(0)}); + {copyInfo.textureOrigin.x, copyInfo.textureOrigin.y, TexelCount(0u)}); const MTLSize copyExtent = ToMTLSize( - {copyInfo.copyExtent.width, copyInfo.copyExtent.height, TexelCount(1)}); + {copyInfo.copyExtent.width, copyInfo.copyExtent.height, TexelCount(1u)}); for (TexelCount z = copyInfo.textureOrigin.z; z < copyInfo.textureOrigin.z + copyInfo.copyExtent.depthOrArrayLayers; ++z) { @@ -1092,8 +1092,8 @@ CommandBuffer::~CommandBuffer() = default; MaybeError CommandBuffer::FillCommands(CommandRecordingContext* commandContext) { - PassIndex nextComputePassNumber{0}; - PassIndex nextRenderPassNumber{0}; + PassIndex nextComputePassNumber{0u}; + PassIndex nextRenderPassNumber{0u}; auto LazyClearSyncScope = [](const SyncScopeResourceUsage& scope, CommandRecordingContext* commandContext) -> MaybeError { @@ -1321,10 +1321,10 @@ case wgpu::TextureDimension::e2D: { const MTLOrigin textureOrigin = ToMTLOrigin({copyInfo.textureOrigin.x, copyInfo.textureOrigin.y, - TexelCount(0)}); + TexelCount(0u)}); const MTLSize copyExtent = ToMTLSize({copyInfo.copyExtent.width, copyInfo.copyExtent.height, - TexelCount(1)}); + TexelCount(1u)}); for (TexelCount z = copyInfo.textureOrigin.z; z < @@ -1405,7 +1405,7 @@ } // TODO(crbug.com/dawn/782): Do a single T2T copy if both are 1D or 3D. - for (TexelCount z{0}; z < copy->copySize.depthOrArrayLayers; ++z) { + for (TexelCount z{0u}; z < copy->copySize.depthOrArrayLayers; ++z) { *sourceZPtr = dchecked_cast<uint32_t>(copy->source.origin.z + z); *destinationZPtr = dchecked_cast<uint32_t>(copy->destination.origin.z + z); @@ -1775,7 +1775,7 @@ bool didDrawInCurrentOcclusionQuery = false; const IndirectDrawMetadata& metadata = GetIndirectDrawMetadata()[renderPassIndex]; - IndirectDrawIndex indirectDrawIndex{0}; + IndirectDrawIndex indirectDrawIndex{0u}; StorageBufferLengthTracker storageBufferLengths{GetDevice()}; VertexBufferTracker vertexBuffers(&storageBufferLengths);
diff --git a/src/dawn/native/metal/PipelineLayoutMTL.mm b/src/dawn/native/metal/PipelineLayoutMTL.mm index fc8e72e..1e19988 100644 --- a/src/dawn/native/metal/PipelineLayoutMTL.mm +++ b/src/dawn/native/metal/PipelineLayoutMTL.mm
@@ -53,7 +53,7 @@ for (BindGroupIndex group : GetBindGroupLayoutsMask()) { mIndexInfo[stage][group].resize(GetBindGroupLayout(group)->GetBindingCount()); - for (BindingIndex bindingIndex{0}; + for (BindingIndex bindingIndex{0u}; bindingIndex < GetBindGroupLayout(group)->GetBindingCount(); ++bindingIndex) { const BindingInfo& bindingInfo = GetBindGroupLayout(group)->GetBindingInfo(bindingIndex);
diff --git a/src/dawn/native/metal/QuerySetMTL.mm b/src/dawn/native/metal/QuerySetMTL.mm index 790a4fe..112d488 100644 --- a/src/dawn/native/metal/QuerySetMTL.mm +++ b/src/dawn/native/metal/QuerySetMTL.mm
@@ -57,7 +57,7 @@ } DAWN_ASSERT(descriptor.counterSet != nullptr); - descriptor.sampleCount = NSUInteger{std::max(count, QueryIndex(1))}; + descriptor.sampleCount = NSUInteger{std::max(count, QueryIndex(1u))}; descriptor.storageMode = MTLStorageModePrivate; if (device->IsToggleEnabled(Toggle::MetalUseSharedModeForCounterSampleBuffer)) { descriptor.storageMode = MTLStorageModeShared;
diff --git a/src/dawn/native/metal/UtilsMetal.mm b/src/dawn/native/metal/UtilsMetal.mm index 371a99f..28f4d82 100644 --- a/src/dawn/native/metal/UtilsMetal.mm +++ b/src/dawn/native/metal/UtilsMetal.mm
@@ -727,7 +727,7 @@ const uint32_t localBytesPerRow = maxBytesPerRow; const uint32_t localBytesPerImage = 0; // workaround case 3 const TexelExtent3D localCopySize = {clampedCopyExtent.width, blockInfo.height, - TexelCount(1)}; + TexelCount(1u)}; for (BlockCount slice : Range(copyExtent.depthOrArrayLayers)) { for (BlockCount row : Range(copyExtent.height)) { @@ -753,7 +753,7 @@ const bool needCopyLastImageAndLastRowSeparately = bufferSize - bufferOffset < sizeRequiredByValidation; if (!needCopyLastImageAndLastRowSeparately) { - const uint32_t localBytesPerImage = copyExtent.depthOrArrayLayers == BlockCount(1) + const uint32_t localBytesPerImage = copyExtent.depthOrArrayLayers == BlockCount(1u) ? 0 : bytesPerImage; // workaround case 3 copy.push_back( @@ -766,10 +766,10 @@ uint64_t currentOffset = bufferOffset; // Doing all the copy except the last image. - if (copyExtent.depthOrArrayLayers > BlockCount(1)) { - const BlockCount localDepthOrArrayLayers = copyExtent.depthOrArrayLayers - BlockCount(1); + if (copyExtent.depthOrArrayLayers > BlockCount(1u)) { + const BlockCount localDepthOrArrayLayers = copyExtent.depthOrArrayLayers - BlockCount(1u); const uint32_t localBytesPerImage = - localDepthOrArrayLayers == BlockCount(1) ? 0 : bytesPerImage; // workaround case 3 + localDepthOrArrayLayers == BlockCount(1u) ? 0 : bytesPerImage; // workaround case 3 const TexelExtent3D localSize = {clampedCopyExtent.width, clampedCopyExtent.height, blockInfo.ToTexelDepth(localDepthOrArrayLayers)}; copy.push_back(TextureBufferCopySplit::CopyInfo( @@ -777,24 +777,24 @@ // Update offset to copy to the last image. const BlockCount copiedBlocks = - (copyExtent.depthOrArrayLayers - BlockCount(1)) * blocksPerImage; + (copyExtent.depthOrArrayLayers - BlockCount(1u)) * blocksPerImage; currentOffset += blockInfo.ToBytes(copiedBlocks); } // Doing all the copy in last image except the last row. - if (copyExtent.height > BlockCount(1)) { + if (copyExtent.height > BlockCount(1u)) { const uint32_t localBytesPerImage = 0; // workaround case 3 const BlockOrigin3D localOrigin = { - origin.x, origin.y, origin.z + copyExtent.depthOrArrayLayers - BlockCount(1)}; - const TexelExtent3D localSize = {clampedCopyExtent.width, - blockInfo.ToTexelHeight(copyExtent.height - BlockCount(1)), - TexelCount(1)}; + origin.x, origin.y, origin.z + copyExtent.depthOrArrayLayers - BlockCount(1u)}; + const TexelExtent3D localSize = { + clampedCopyExtent.width, blockInfo.ToTexelHeight(copyExtent.height - BlockCount(1u)), + TexelCount(1u)}; copy.push_back(TextureBufferCopySplit::CopyInfo(currentOffset, bytesPerRow, localBytesPerImage, blockInfo.ToTexel(localOrigin), localSize)); // Update offset to copy to the last row. - const BlockCount copiedBlocks = (copyExtent.height - BlockCount(1)) * blocksPerRow; + const BlockCount copiedBlocks = (copyExtent.height - BlockCount(1u)) * blocksPerRow; currentOffset += blockInfo.ToBytes(copiedBlocks); } @@ -803,14 +803,14 @@ const uint32_t lastRowDataSize = blockInfo.ToBytes(copyExtent.width); const uint32_t lastImageDataSize = 0; // workaround case 3 const TexelCount lastRowCopyExtentHeight = - clampedCopyExtent.height - blockInfo.ToTexelHeight(copyExtent.height - BlockCount(1)); + clampedCopyExtent.height - blockInfo.ToTexelHeight(copyExtent.height - BlockCount(1u)); DAWN_ASSERT(lastRowCopyExtentHeight <= blockInfo.height); - const BlockOrigin3D localOrigin = {origin.x, origin.y + copyExtent.height - BlockCount(1), - origin.z + copyExtent.depthOrArrayLayers - BlockCount(1)}; + const BlockOrigin3D localOrigin = {origin.x, origin.y + copyExtent.height - BlockCount(1u), + origin.z + copyExtent.depthOrArrayLayers - BlockCount(1u)}; copy.push_back(TextureBufferCopySplit::CopyInfo( currentOffset, lastRowDataSize, lastImageDataSize, blockInfo.ToTexel(localOrigin), - {clampedCopyExtent.width, lastRowCopyExtentHeight, TexelCount(1)})); + {clampedCopyExtent.width, lastRowCopyExtentHeight, TexelCount(1u)})); return copy; }
diff --git a/src/dawn/native/opengl/CommandBufferGL.cpp b/src/dawn/native/opengl/CommandBufferGL.cpp index dcc5532..e83b2d7 100644 --- a/src/dawn/native/opengl/CommandBufferGL.cpp +++ b/src/dawn/native/opengl/CommandBufferGL.cpp
@@ -628,7 +628,7 @@ FlatBindingIndex ssboIndex = bindingIndexInfo[groupIndex][bindingIndex]; if (ssboIndex >= mInternalArrayLengthBufferData.size()) { - mInternalArrayLengthBufferData.resize(ssboIndex + FlatBindingIndex(4)); + mInternalArrayLengthBufferData.resize(ssboIndex + FlatBindingIndex(4u)); } mInternalArrayLengthBufferData[ssboIndex] = static_cast<uint32_t>(size); @@ -813,8 +813,8 @@ return {}; }; - PassIndex nextComputePassNumber{0}; - PassIndex nextRenderPassNumber{0}; + PassIndex nextComputePassNumber{0u}; + PassIndex nextRenderPassNumber{0u}; Command type; while (mCommands.NextCommandId(&type)) { @@ -1010,7 +1010,7 @@ DAWN_ASSERT(texture->GetArrayLayers() == 6); const uint64_t bytesPerImage = blockInfo.ToBytes(dst.blocksPerRow * dst.rowsPerImage); - for (TexelCount z{0}; z < copySize.depthOrArrayLayers; ++z) { + for (TexelCount z{0u}; z < copySize.depthOrArrayLayers; ++z) { GLenum cubeMapTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + dchecked_cast<uint32_t>(z + src.origin.z); DAWN_GL_TRY( @@ -1033,7 +1033,7 @@ case wgpu::TextureDimension::e3D: { const uint64_t bytesPerImage = blockInfo.ToBytes(dst.blocksPerRow * dst.rowsPerImage); - for (TexelCount z{0}; z < copySize.depthOrArrayLayers; ++z) { + for (TexelCount z{0u}; z < copySize.depthOrArrayLayers; ++z) { DAWN_GL_TRY( gl, FramebufferTextureLayer( GL_READ_FRAMEBUFFER, glAttachment, texture->GetHandle(), @@ -1290,7 +1290,7 @@ GLuint fbo = 0; const IndirectDrawMetadata& metadata = GetIndirectDrawMetadata()[renderPassIndex]; - IndirectDrawIndex indirectDrawIndex{0}; + IndirectDrawIndex indirectDrawIndex{0u}; // Create the framebuffer used for this render pass and calls the correct glDrawBuffers { @@ -1751,7 +1751,7 @@ DAWN_ASSERT(texture->GetArrayLayers() == 6); const uint8_t* pointer = static_cast<const uint8_t*>(data); TexelCount baseLayer = destination.origin.z; - for (TexelCount l{0}; l < copySize.depthOrArrayLayers; ++l) { + for (TexelCount l{0u}; l < copySize.depthOrArrayLayers; ++l) { GLenum cubeMapTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + dchecked_cast<uint32_t>(baseLayer + l); DAWN_GL_TRY( @@ -1798,7 +1798,7 @@ DAWN_ASSERT(texture->GetArrayLayers() == 6); const uint8_t* pointer = static_cast<const uint8_t*>(data); TexelCount baseLayer = destination.origin.z; - for (TexelCount l{0}; l < copySize.depthOrArrayLayers; ++l) { + for (TexelCount l{0u}; l < copySize.depthOrArrayLayers; ++l) { const uint8_t* d = DAWN_UNSAFE_TODO(pointer + dchecked_cast<uint32_t>(l)) * bytesPerImage; GLenum cubeMapTarget = @@ -1866,7 +1866,7 @@ DAWN_ASSERT(texture->GetArrayLayers() == 6); const uint8_t* pointer = static_cast<const uint8_t*>(data); TexelCount baseLayer = destination.origin.z; - for (TexelCount l{0}; l < copySize.depthOrArrayLayers; ++l) { + for (TexelCount l{0u}; l < copySize.depthOrArrayLayers; ++l) { GLenum cubeMapTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + dchecked_cast<uint32_t>(baseLayer + l); DAWN_GL_TRY( @@ -1908,7 +1908,7 @@ DAWN_ASSERT(texture->GetArrayLayers() == 6); const uint8_t* pointer = static_cast<const uint8_t*>(data); TexelCount baseLayer = destination.origin.z; - for (TexelCount l{0}; l < copySize.depthOrArrayLayers; ++l) { + for (TexelCount l{0u}; l < copySize.depthOrArrayLayers; ++l) { const uint8_t* d = pointer; GLenum cubeMapTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + dchecked_cast<uint32_t>(baseLayer + l);
diff --git a/src/dawn/native/opengl/PipelineGL.cpp b/src/dawn/native/opengl/PipelineGL.cpp index 225efd5..40992c4 100644 --- a/src/dawn/native/opengl/PipelineGL.cpp +++ b/src/dawn/native/opengl/PipelineGL.cpp
@@ -121,7 +121,7 @@ mUnitsForTextures.resize(layout->GetNumSampledTextures()); // Assign combined texture/samplers to GL texture units. - TextureUnit textureUnit{0}; + TextureUnit textureUnit{0u}; for (const auto& combined : combinedSamplers) { // All the texture/samplers of a binding_array are set in a single glUniform1iv, gather them // all in this vector.
diff --git a/src/dawn/native/opengl/PipelineLayoutGL.cpp b/src/dawn/native/opengl/PipelineLayoutGL.cpp index c934e9b..1308099 100644 --- a/src/dawn/native/opengl/PipelineLayoutGL.cpp +++ b/src/dawn/native/opengl/PipelineLayoutGL.cpp
@@ -36,17 +36,17 @@ PipelineLayout::PipelineLayout(Device* device, const UnpackedPtr<PipelineLayoutDescriptor>& descriptor) : PipelineLayoutBase(device, descriptor) { - FlatBindingIndex uboIndex{0}; - FlatBindingIndex samplerIndex{0}; - FlatBindingIndex sampledTextureIndex{0}; - FlatBindingIndex ssboIndex{0}; - FlatBindingIndex storageTextureIndex{0}; + FlatBindingIndex uboIndex{0u}; + FlatBindingIndex samplerIndex{0u}; + FlatBindingIndex sampledTextureIndex{0u}; + FlatBindingIndex ssboIndex{0u}; + FlatBindingIndex storageTextureIndex{0u}; for (BindGroupIndex group : GetBindGroupLayoutsMask()) { const BindGroupLayoutInternalBase* bgl = GetBindGroupLayout(group); mIndexInfo[group].resize(bgl->GetBindingCount()); - for (BindingIndex bindingIndex{0}; bindingIndex < bgl->GetBindingCount(); ++bindingIndex) { + for (BindingIndex bindingIndex{0u}; bindingIndex < bgl->GetBindingCount(); ++bindingIndex) { const BindingInfo& bindingInfo = bgl->GetBindingInfo(bindingIndex); if (bindingInfo.visibility == wgpu::ShaderStage::None) { continue;
diff --git a/src/dawn/native/opengl/QueueGL.cpp b/src/dawn/native/opengl/QueueGL.cpp index 5e2a009..3857ee0 100644 --- a/src/dawn/native/opengl/QueueGL.cpp +++ b/src/dawn/native/opengl/QueueGL.cpp
@@ -319,7 +319,7 @@ // Queue::SubmitImpl(), it's safe to use ExecuteGL(). return device->ExecuteGL(SubmitMode::Passive, [&](const OpenGLFunctions& gl) -> auto { return mFencesInFlight.Use([&](auto fencesInFlight) -> ResultOrError<ExecutionSerial> { - ExecutionSerial fenceSerial{0}; + ExecutionSerial fenceSerial{0u}; while (!fencesInFlight->empty()) { auto [sync, tentativeSerial] = fencesInFlight->front(); @@ -327,7 +327,7 @@ // as we see one that's not ready. GLenum result; DAWN_TRY_ASSIGN(result, - sync->ClientWait(gl, EGL_SYNC_FLUSH_COMMANDS_BIT, Nanoseconds(0))); + sync->ClientWait(gl, EGL_SYNC_FLUSH_COMMANDS_BIT, Nanoseconds(0u))); if (result == EGL_TIMEOUT_EXPIRED) { return fenceSerial; }
diff --git a/src/dawn/native/opengl/ShaderModuleGL.cpp b/src/dawn/native/opengl/ShaderModuleGL.cpp index f5e304a..7ed1039 100644 --- a/src/dawn/native/opengl/ShaderModuleGL.cpp +++ b/src/dawn/native/opengl/ShaderModuleGL.cpp
@@ -125,7 +125,7 @@ // Dawn takes BindGroupIndex + BindingIndex. BindGroupIndex group; BindingIndex index; - BindingIndex shaderArraySize = BindingIndex(1); + BindingIndex shaderArraySize = BindingIndex(1u); // Tint takes the post-remapping binding point. tint::BindingPoint remappedBinding;
diff --git a/src/dawn/native/opengl/ShaderModuleGL.h b/src/dawn/native/opengl/ShaderModuleGL.h index 53a1f51..7713b12 100644 --- a/src/dawn/native/opengl/ShaderModuleGL.h +++ b/src/dawn/native/opengl/ShaderModuleGL.h
@@ -58,7 +58,7 @@ X(BindingIndex, index) \ /* Return the array size of the element in the WGSL / GLSL as OpenGL requires that a */ \ /* non-arrayed (arraySize = 1) binding uses glUniform1i and not glUniform1iv. */ \ - X(BindingIndex, shaderArraySize, 1) + X(BindingIndex, shaderArraySize, 1u) DAWN_SERIALIZABLE(struct, CombinedSamplerElement, COMBINED_SAMPLER_ELEMENT_MEMBERS){}; #undef COMBINED_SAMPLER_ELEMENT_MEMBERS
diff --git a/src/dawn/native/vulkan/BindGroupLayoutVk.cpp b/src/dawn/native/vulkan/BindGroupLayoutVk.cpp index cc2abb1..029d18b 100644 --- a/src/dawn/native/vulkan/BindGroupLayoutVk.cpp +++ b/src/dawn/native/vulkan/BindGroupLayoutVk.cpp
@@ -97,7 +97,7 @@ // Vulkan descriptor set layouts have one entry for binding_array. Only handle their first // element as subsequent ones will be part of the already added // VkDescriptorSetLayoutBinding. - if (bindingInfo.indexInArray != BindingIndex(0)) { + if (bindingInfo.indexInArray != BindingIndex(0u)) { continue; } @@ -138,7 +138,7 @@ // the maximum number of planes that an external format can have here. The number // of overall YCbCr descriptors will be relatively small and these pools are not an // overall bottleneck on memory usage. - DAWN_CHECK(bindingInfo.arraySize == BindingIndex(1)); + DAWN_CHECK(bindingInfo.arraySize == BindingIndex(1u)); descriptorCount = 3; } }
diff --git a/src/dawn/native/vulkan/CommandBufferVk.cpp b/src/dawn/native/vulkan/CommandBufferVk.cpp index 037fbab..382b359 100644 --- a/src/dawn/native/vulkan/CommandBufferVk.cpp +++ b/src/dawn/native/vulkan/CommandBufferVk.cpp
@@ -512,7 +512,7 @@ DAWN_ASSERT(availability.size() == querySet->GetQueryCount()); ForEachAvailableQueryRange( - QueryIndex(0), availability.size(), [&](QueryIndex i) { return availability[i]; }, + QueryIndex(0u), availability.size(), [&](QueryIndex i) { return availability[i]; }, [&](QueryIndex start, QueryIndex count) { device->fn.CmdResetQueryPool(commands, ToBackend(querySet)->GetHandle(), uint32_t{start}, uint32_t{count}); @@ -1121,8 +1121,8 @@ return {}; }; - PassIndex nextComputePassNumber{0}; - PassIndex nextRenderPassNumber{0}; + PassIndex nextComputePassNumber{0u}; + PassIndex nextRenderPassNumber{0u}; Command type; while (mCommands.NextCommandId(&type)) { @@ -1685,7 +1685,7 @@ VkCommandBuffer commands = recordingContext->commandBuffer; const IndirectDrawMetadata& metadata = GetIndirectDrawMetadata()[renderPassIndex]; - IndirectDrawIndex indirectDrawIndex{0}; + IndirectDrawIndex indirectDrawIndex{0u}; // Write timestamp at the beginning of render pass if it's set. // We've observed that this must be called before the render pass or the timestamps produced
diff --git a/src/dawn/native/vulkan/DescriptorSetAllocator.h b/src/dawn/native/vulkan/DescriptorSetAllocator.h index 67254ac..9d50c6d 100644 --- a/src/dawn/native/vulkan/DescriptorSetAllocator.h +++ b/src/dawn/native/vulkan/DescriptorSetAllocator.h
@@ -99,7 +99,7 @@ SetIndex setIndex; }; SerialQueue<ExecutionSerial, Deallocation> mPendingDeallocations; - ExecutionSerial mLastDeallocationSerial = ExecutionSerial(0); + ExecutionSerial mLastDeallocationSerial = ExecutionSerial(0u); // Used to guard all public member functions. Mutex mMutex;
diff --git a/src/dawn/native/vulkan/PipelineLayoutVk.cpp b/src/dawn/native/vulkan/PipelineLayoutVk.cpp index 013bbef..ad53df3 100644 --- a/src/dawn/native/vulkan/PipelineLayoutVk.cpp +++ b/src/dawn/native/vulkan/PipelineLayoutVk.cpp
@@ -57,7 +57,7 @@ // The first VkDescriptorSetLayouts are the for framebuffer fetch and/or the resource table if // needed. - BindGroupIndex startOfBindGroups{0}; + BindGroupIndex startOfBindGroups{0u}; if (specialization.framebufferFetchAttachmentCount > 0) { DAWN_TRY_ASSIGN(setLayouts[startOfBindGroups], ToBackend(GetDevice())
diff --git a/src/dawn/native/vulkan/QueueVk.cpp b/src/dawn/native/vulkan/QueueVk.cpp index deb4a89..36c7433 100644 --- a/src/dawn/native/vulkan/QueueVk.cpp +++ b/src/dawn/native/vulkan/QueueVk.cpp
@@ -132,7 +132,7 @@ Device* device = ToBackend(GetDevice()); return mFencesInFlight.Use([&](auto fencesInFlight) -> ResultOrError<ExecutionSerial> { - ExecutionSerial fenceSerial(0); + ExecutionSerial fenceSerial(0u); while (!fencesInFlight->empty()) { VkFence fence = fencesInFlight->front().first; ExecutionSerial tentativeSerial = fencesInFlight->front().second;
diff --git a/src/dawn/native/vulkan/ShaderModuleVk.cpp b/src/dawn/native/vulkan/ShaderModuleVk.cpp index 5764ab0..74fe3d7 100644 --- a/src/dawn/native/vulkan/ShaderModuleVk.cpp +++ b/src/dawn/native/vulkan/ShaderModuleVk.cpp
@@ -135,7 +135,7 @@ // The first VkDescriptorSetLayout is the one for the framebuffer fetch and/or resource table if // needed and pushes the bindings for all other bindgroups. - BindGroupIndex startOfBindGroups{0}; + BindGroupIndex startOfBindGroups{0u}; std::unordered_map<uint32_t, tint::BindingPoint> framebuffer_fetch_bindings; if (in.pipelineUsesFramebufferFetch) { @@ -144,11 +144,11 @@ framebuffer_fetch_bindings[i] = {static_cast<uint32_t>(startOfBindGroups), i}; } } - startOfBindGroups = startOfBindGroups + BindGroupIndex(1); + startOfBindGroups = startOfBindGroups + BindGroupIndex(1u); } if (in.layout->UsesResourceTable()) { - startOfBindGroups = BindGroupIndex(1); + startOfBindGroups = BindGroupIndex(1u); } auto ToWGSLBindPoint = [](BindGroupIndex group, BindingNumber binding) -> tint::BindingPoint {
diff --git a/src/dawn/native/vulkan/TextureVk.cpp b/src/dawn/native/vulkan/TextureVk.cpp index 8d14866..83a12e6 100644 --- a/src/dawn/native/vulkan/TextureVk.cpp +++ b/src/dawn/native/vulkan/TextureVk.cpp
@@ -1363,7 +1363,7 @@ TextureCopy textureCopy; textureCopy.aspect = range.aspects; textureCopy.mipLevel = level; - textureCopy.origin = {TexelCount{0}, TexelCount{0}, TexelCount{layer}}; + textureCopy.origin = {TexelCount{0u}, TexelCount{0u}, TexelCount{layer}}; textureCopy.texture = this; regions.push_back(
diff --git a/src/dawn/native/vulkan/UtilsVulkan.cpp b/src/dawn/native/vulkan/UtilsVulkan.cpp index a9f6b90..9a1058d 100644 --- a/src/dawn/native/vulkan/UtilsVulkan.cpp +++ b/src/dawn/native/vulkan/UtilsVulkan.cpp
@@ -255,8 +255,8 @@ case wgpu::TextureDimension::Undefined: DAWN_UNREACHABLE(); case wgpu::TextureDimension::e1D: - DAWN_ASSERT(textureCopy.origin.z == TexelCount{0} && - copySizeTexels.depthOrArrayLayers == TexelCount{1}); + DAWN_ASSERT(textureCopy.origin.z == TexelCount{0u} && + copySizeTexels.depthOrArrayLayers == TexelCount{1u}); region.imageOffset.x = dchecked_cast<uint32_t>(textureCopy.origin.x); region.imageOffset.y = 0; region.imageOffset.z = 0;
diff --git a/src/dawn/native/webgpu/CommandBufferWGPU.cpp b/src/dawn/native/webgpu/CommandBufferWGPU.cpp index 5f146b7..88290d3 100644 --- a/src/dawn/native/webgpu/CommandBufferWGPU.cpp +++ b/src/dawn/native/webgpu/CommandBufferWGPU.cpp
@@ -1011,8 +1011,8 @@ WGPUCommandEncoder innerEncoder = wgpu.deviceCreateCommandEncoder(ToBackend(GetDevice())->GetInnerHandle(), nullptr); - PassIndex nextComputePassNumber{0}; - PassIndex nextRenderPassNumber{0}; + PassIndex nextComputePassNumber{0u}; + PassIndex nextRenderPassNumber{0u}; Command type; while (mCommands.NextCommandId(&type)) {
diff --git a/src/dawn/native/webgpu/TextureWGPU.cpp b/src/dawn/native/webgpu/TextureWGPU.cpp index 5ef2265..0260738 100644 --- a/src/dawn/native/webgpu/TextureWGPU.cpp +++ b/src/dawn/native/webgpu/TextureWGPU.cpp
@@ -313,7 +313,7 @@ } // We only write out the beginning of each row, the rest is padding. - for (BlockCount blockRow{0}; blockRow < blockRows; ++blockRow) { + for (BlockCount blockRow{0u}; blockRow < blockRows; ++blockRow) { const void* data = wgpu->bufferGetConstMappedRange( copyBuffer, dchecked_cast<uint32_t>(blockRow) * alignedBytesPerRow, mappableBytesPerRow); @@ -404,10 +404,10 @@ uint32_t alignedBytesPerRow = Align(usedBytesPerRow, 256); BlockCount maxBlockRowsPerRead{CaptureContext::kCopyBufferSize / alignedBytesPerRow}; - DAWN_ASSERT(maxBlockRowsPerRead > BlockCount{0}); + DAWN_ASSERT(maxBlockRowsPerRead > BlockCount{0u}); - for (BlockCount z{0}; z < blockSize.depthOrArrayLayers; ++z) { - for (BlockCount y{0}; y < blockSize.height; y += maxBlockRowsPerRead) { + for (BlockCount z{0u}; z < blockSize.depthOrArrayLayers; ++z) { + for (BlockCount y{0u}; y < blockSize.height; y += maxBlockRowsPerRead) { BlockCount blockRows = std::min(maxBlockRowsPerRead, blockSize.height - y); // Copy Data from Texture to Buffer. Then map and write buffer.
diff --git a/src/dawn/native/webgpu_absl_format.cpp b/src/dawn/native/webgpu_absl_format.cpp index 966dd21..2e9c13e 100644 --- a/src/dawn/native/webgpu_absl_format.cpp +++ b/src/dawn/native/webgpu_absl_format.cpp
@@ -97,7 +97,7 @@ const absl::FormatConversionSpec& spec, absl::FormatSink* s) { s->Append(absl::StrFormat("{ binding: %u, visibility: %s, ", value.binding, value.visibility)); - if (value.arraySize != BindingIndex(1)) { + if (value.arraySize != BindingIndex(1u)) { s->Append(absl::StrFormat("arraySize: %u, indexInArray: %u, ", value.arraySize, value.indexInArray)); }
diff --git a/src/dawn/platform/WorkerThread.cpp b/src/dawn/platform/WorkerThread.cpp index 9462a46..6ec9525 100644 --- a/src/dawn/platform/WorkerThread.cpp +++ b/src/dawn/platform/WorkerThread.cpp
@@ -169,7 +169,7 @@ JobStatus AsyncWorkerThreadPool::TaskHandlingJobLoop() { // By default, wait for 100ms between yielding. - static constexpr Nanoseconds kWaitDuration = Nanoseconds(100000000); + static constexpr Nanoseconds kWaitDuration = Nanoseconds(100000000u); Ref<AsyncTaskHandleImpl> task = nullptr; mTaskTracking.Use<NotifyType::None>([&](auto taskTracking) {
diff --git a/src/dawn/tests/end2end/PipelineCachingTests.cpp b/src/dawn/tests/end2end/PipelineCachingTests.cpp index b11180b..b5d5bfe 100644 --- a/src/dawn/tests/end2end/PipelineCachingTests.cpp +++ b/src/dawn/tests/end2end/PipelineCachingTests.cpp
@@ -156,7 +156,7 @@ wgpu::ComputePipelineDescriptor desc; desc.compute.module = utils::CreateShaderModule(device, kComputeShaderDefault.data()); desc.compute.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(0), device.CreateComputePipeline(&desc)); + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(0u), device.CreateComputePipeline(&desc)); } // Second time should create fine with no cache hits since cache is disabled. @@ -165,7 +165,7 @@ wgpu::ComputePipelineDescriptor desc; desc.compute.module = utils::CreateShaderModule(device, kComputeShaderDefault.data()); desc.compute.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(0), device.CreateComputePipeline(&desc)); + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(0u), device.CreateComputePipeline(&desc)); } } @@ -178,14 +178,14 @@ // First creation should create a cache entry. wgpu::ComputePipeline pipeline; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(counts.shaderModule + counts.pipeline), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(counts.shaderModule + counts.pipeline), pipeline = device.CreateComputePipeline(&desc)); // Second creation on the same device should just return from frontend cache and should not // call out to the blob cache. EXPECT_CALL(mMockCache, LoadData).Times(0); wgpu::ComputePipeline samePipeline; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(0), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(0u), samePipeline = device.CreateComputePipeline(&desc)); EXPECT_EQ(pipeline.Get() == samePipeline.Get(), !UsesWire()); } @@ -200,7 +200,7 @@ wgpu::ComputePipelineDescriptor desc; desc.compute.module = utils::CreateShaderModule(device, kComputeShaderDefault.data()); desc.compute.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(counts.shaderModule + counts.pipeline), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(counts.shaderModule + counts.pipeline), device.CreateComputePipeline(&desc)); } @@ -210,7 +210,7 @@ wgpu::ComputePipelineDescriptor desc; desc.compute.module = utils::CreateShaderModule(device, kComputeShaderDefault.data()); desc.compute.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(counts.shaderModule + counts.pipeline), Add(0), + EXPECT_CACHE_STATS(mMockCache, Hit(counts.shaderModule + counts.pipeline), Add(0u), device.CreateComputePipeline(&desc)); } } @@ -224,7 +224,7 @@ wgpu::ComputePipelineDescriptor desc; desc.compute.module = utils::CreateShaderModule(device, kComputeShaderDefault.data()); desc.compute.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(counts.shaderModule + counts.pipeline), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(counts.shaderModule + counts.pipeline), device.CreateComputePipeline(&desc)); } @@ -235,7 +235,7 @@ desc.compute.module = utils::CreateShaderModule(device, kComputeShaderDefault.data()); desc.compute.entryPoint = "main"; desc.layout = utils::MakeBasicPipelineLayout(device, {}); - EXPECT_CACHE_STATS(mMockCache, Hit(counts.shaderModule + counts.pipeline), Add(0), + EXPECT_CACHE_STATS(mMockCache, Hit(counts.shaderModule + counts.pipeline), Add(0u), device.CreateComputePipeline(&desc)); } } @@ -248,7 +248,7 @@ wgpu::ComputePipelineDescriptor desc; desc.compute.module = utils::CreateShaderModule(device, kComputeShaderDefault.data()); desc.compute.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(counts.shaderModule + counts.pipeline), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(counts.shaderModule + counts.pipeline), device.CreateComputePipeline(&desc)); } @@ -259,7 +259,7 @@ desc.compute.module = utils::CreateShaderModule(device, kComputeShaderMultipleEntryPoints.data()); desc.compute.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(counts.shaderModule + counts.pipeline), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(counts.shaderModule + counts.pipeline), device.CreateComputePipeline(&desc)); } @@ -270,7 +270,7 @@ desc.compute.module = utils::CreateShaderModule(device, kComputeShaderMultipleEntryPoints.data()); desc.compute.entryPoint = "main2"; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(counts.shaderModule + counts.pipeline), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(counts.shaderModule + counts.pipeline), device.CreateComputePipeline(&desc)); } } @@ -284,7 +284,7 @@ wgpu::ComputePipelineDescriptor desc; desc.compute.module = utils::CreateShaderModule(device, kComputeShaderDefault.data()); desc.compute.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(counts.shaderModule + counts.pipeline), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(counts.shaderModule + counts.pipeline), device.CreateComputePipeline(&desc)); } @@ -294,7 +294,7 @@ wgpu::ComputePipelineDescriptor desc; desc.compute.module = utils::CreateShaderModule(device, kComputeShaderDefault.data()); desc.compute.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(counts.shaderModule + counts.pipeline), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(counts.shaderModule + counts.pipeline), device.CreateComputePipeline(&desc)); } } @@ -314,7 +314,7 @@ desc.vertex.entryPoint = "main"; desc.cFragment.module = utils::CreateShaderModule(device, kFragmentShaderDefault.data()); desc.cFragment.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(0), device.CreateRenderPipeline(&desc)); + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(0u), device.CreateRenderPipeline(&desc)); } // Second time should create fine with no cache hits since cache is disabled. @@ -325,7 +325,7 @@ desc.vertex.entryPoint = "main"; desc.cFragment.module = utils::CreateShaderModule(device, kFragmentShaderDefault.data()); desc.cFragment.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(0), device.CreateRenderPipeline(&desc)); + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(0u), device.CreateRenderPipeline(&desc)); } } @@ -340,14 +340,14 @@ // First creation should create a cache entry. wgpu::RenderPipeline pipeline; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(2 * counts.shaderModule + counts.pipeline), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(2 * counts.shaderModule + counts.pipeline), pipeline = device.CreateRenderPipeline(&desc)); // Second creation on the same device should just return from frontend cache and should not // call out to the blob cache. EXPECT_CALL(mMockCache, LoadData).Times(0); wgpu::RenderPipeline samePipeline; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(0), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(0u), samePipeline = device.CreateRenderPipeline(&desc)); EXPECT_EQ(pipeline.Get() == samePipeline.Get(), !UsesWire()); } @@ -364,7 +364,7 @@ desc.vertex.entryPoint = "main"; desc.cFragment.module = utils::CreateShaderModule(device, kFragmentShaderDefault.data()); desc.cFragment.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(2 * counts.shaderModule + counts.pipeline), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(2 * counts.shaderModule + counts.pipeline), device.CreateRenderPipeline(&desc)); } @@ -376,7 +376,7 @@ desc.vertex.entryPoint = "main"; desc.cFragment.module = utils::CreateShaderModule(device, kFragmentShaderDefault.data()); desc.cFragment.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(2 * counts.shaderModule + counts.pipeline), Add(0), + EXPECT_CACHE_STATS(mMockCache, Hit(2 * counts.shaderModule + counts.pipeline), Add(0u), device.CreateRenderPipeline(&desc)); } } @@ -392,7 +392,7 @@ desc.vertex.entryPoint = "main"; desc.cFragment.module = utils::CreateShaderModule(device, kFragmentShaderDefault.data()); desc.cFragment.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(2 * counts.shaderModule + counts.pipeline), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(2 * counts.shaderModule + counts.pipeline), device.CreateRenderPipeline(&desc)); } @@ -405,7 +405,7 @@ desc.cFragment.module = utils::CreateShaderModule(device, kFragmentShaderDefault.data()); desc.cFragment.entryPoint = "main"; desc.layout = utils::MakeBasicPipelineLayout(device, {}); - EXPECT_CACHE_STATS(mMockCache, Hit(2 * counts.shaderModule + counts.pipeline), Add(0), + EXPECT_CACHE_STATS(mMockCache, Hit(2 * counts.shaderModule + counts.pipeline), Add(0u), device.CreateRenderPipeline(&desc)); } } @@ -421,7 +421,7 @@ desc.vertex.entryPoint = "main"; desc.cFragment.module = utils::CreateShaderModule(device, kFragmentShaderDefault.data()); desc.cFragment.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(2 * counts.shaderModule + counts.pipeline), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(2 * counts.shaderModule + counts.pipeline), device.CreateRenderPipeline(&desc)); } @@ -450,7 +450,7 @@ desc.vertex.entryPoint = "main"; desc.cFragment.module = utils::CreateShaderModule(device, kFragmentShaderDefault.data()); desc.cFragment.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(2 * counts.shaderModule + counts.pipeline), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(2 * counts.shaderModule + counts.pipeline), device.CreateRenderPipeline(&desc)); } @@ -504,7 +504,7 @@ desc.cFragment.module = utils::CreateShaderModule(device, kFragmentShaderMultipleOutput.data()); desc.cFragment.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(2 * counts.shaderModule + counts.pipeline), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(2 * counts.shaderModule + counts.pipeline), device.CreateRenderPipeline(&desc)); } @@ -568,7 +568,7 @@ {0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform}, }), }); - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(2 * counts.shaderModule + counts.pipeline), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(2 * counts.shaderModule + counts.pipeline), device.CreateRenderPipeline(&desc)); } @@ -662,7 +662,7 @@ desc.vertex.entryPoint = "main"; desc.cFragment.module = utils::CreateShaderModule(device, kFragmentShaderDefault.data()); desc.cFragment.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(2 * counts.shaderModule + counts.pipeline), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(2 * counts.shaderModule + counts.pipeline), device.CreateRenderPipeline(&desc)); } @@ -674,7 +674,7 @@ desc.vertex.entryPoint = "main"; desc.cFragment.module = utils::CreateShaderModule(device, kFragmentShaderDefault.data()); desc.cFragment.entryPoint = "main"; - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(2 * counts.shaderModule + counts.pipeline), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(2 * counts.shaderModule + counts.pipeline), device.CreateRenderPipeline(&desc)); } }
diff --git a/src/dawn/tests/end2end/ShaderModuleCachingTests.cpp b/src/dawn/tests/end2end/ShaderModuleCachingTests.cpp index c883a5d..c2b10cd 100644 --- a/src/dawn/tests/end2end/ShaderModuleCachingTests.cpp +++ b/src/dawn/tests/end2end/ShaderModuleCachingTests.cpp
@@ -66,14 +66,14 @@ // cache. { wgpu::Device device = CreateDevice(); - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(0), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(0u), utils::CreateShaderModule(device, kComputeShaderDefault.data())); } // Second time should create fine with no cache hits since cache is disabled. { wgpu::Device device = CreateDevice(); - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(0), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(0u), utils::CreateShaderModule(device, kComputeShaderDefault.data())); } } @@ -83,7 +83,7 @@ // First creation should create a cache entry. wgpu::ShaderModule shaderModule; EXPECT_CACHE_STATS( - mMockCache, Hit(0), Add(1), + mMockCache, Hit(0u), Add(1u), shaderModule = utils::CreateShaderModule(device, kComputeShaderDefault.data())); // Second creation on the same device should just return from frontend cache and should not @@ -91,7 +91,7 @@ EXPECT_CALL(mMockCache, LoadData).Times(0); wgpu::ShaderModule sameShaderModule; EXPECT_CACHE_STATS( - mMockCache, Hit(0), Add(0), + mMockCache, Hit(0u), Add(0u), sameShaderModule = utils::CreateShaderModule(device, kComputeShaderDefault.data())); EXPECT_EQ(shaderModule.Get() == sameShaderModule.Get(), !UsesWire()); @@ -104,14 +104,14 @@ // First time should create and write out to the blob cache. { wgpu::Device device = CreateDevice(); - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(1), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(1u), utils::CreateShaderModule(device, kComputeShaderDefault.data())); } // Second time should create shader module using the blob cache. { wgpu::Device device = CreateDevice(); - EXPECT_CACHE_STATS(mMockCache, Hit(1), Add(0), + EXPECT_CACHE_STATS(mMockCache, Hit(1u), Add(0u), utils::CreateShaderModule(device, kComputeShaderDefault.data())); } } @@ -122,7 +122,7 @@ // First time should create and write out to the cache. { wgpu::Device device = CreateDevice(); - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(1), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(1u), utils::CreateShaderModule(device, kComputeShaderDefault.data())); } @@ -130,7 +130,7 @@ { wgpu::Device device = CreateDevice(); EXPECT_CACHE_STATS( - mMockCache, Hit(0), Add(1), + mMockCache, Hit(0u), Add(1u), utils::CreateShaderModule(device, kComputeShaderMultipleEntryPoints.data())); } } @@ -141,14 +141,14 @@ // First time should create and write out to the cache. { wgpu::Device device = CreateDevice("isolation key 1"); - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(1), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(1u), utils::CreateShaderModule(device, kComputeShaderDefault.data())); } // Second time should also create and write out to the cache. { wgpu::Device device = CreateDevice("isolation key 2"); - EXPECT_CACHE_STATS(mMockCache, Hit(0), Add(1), + EXPECT_CACHE_STATS(mMockCache, Hit(0u), Add(1u), utils::CreateShaderModule(device, kComputeShaderDefault.data())); } }
diff --git a/src/dawn/tests/unittests/ITypArrayTests.cpp b/src/dawn/tests/unittests/ITypArrayTests.cpp index 0212df7..dbb98a4 100644 --- a/src/dawn/tests/unittests/ITypArrayTests.cpp +++ b/src/dawn/tests/unittests/ITypArrayTests.cpp
@@ -41,12 +41,12 @@ // Test that the expected array methods can be constexpr struct ConstexprTest { - static constexpr Array kArr = {Val(0), Val(1), Val(2), Val(3), Val(4), - Val(5), Val(6), Val(7), Val(8), Val(9)}; + static constexpr Array kArr = {Val(0u), Val(1u), Val(2u), Val(3u), Val(4u), + Val(5u), Val(6u), Val(7u), Val(8u), Val(9u)}; - static_assert(kArr[Key(3)] == Val(3)); - static_assert(kArr.at(Key(7)) == Val(7)); - static_assert(kArr.size() == Key(10)); + static_assert(kArr[Key(3u)] == Val(3u)); + static_assert(kArr.at(Key(7u)) == Val(7u)); + static_assert(kArr.size() == Key(10u)); }; }; @@ -54,22 +54,22 @@ TEST_F(ITypArrayTest, Indexing) { Array arr; { - arr[Key(2)] = Val(5); - arr[Key(1)] = Val(9); - arr[Key(9)] = Val(2); + arr[Key(2u)] = Val(5u); + arr[Key(1u)] = Val(9u); + arr[Key(9u)] = Val(2u); - ASSERT_EQ(arr[Key(2)], Val(5)); - ASSERT_EQ(arr[Key(1)], Val(9)); - ASSERT_EQ(arr[Key(9)], Val(2)); + ASSERT_EQ(arr[Key(2u)], Val(5u)); + ASSERT_EQ(arr[Key(1u)], Val(9u)); + ASSERT_EQ(arr[Key(9u)], Val(2u)); } { - arr.at(Key(4)) = Val(5); - arr.at(Key(3)) = Val(8); - arr.at(Key(1)) = Val(7); + arr.at(Key(4u)) = Val(5u); + arr.at(Key(3u)) = Val(8u); + arr.at(Key(1u)) = Val(7u); - ASSERT_EQ(arr.at(Key(4)), Val(5)); - ASSERT_EQ(arr.at(Key(3)), Val(8)); - ASSERT_EQ(arr.at(Key(1)), Val(7)); + ASSERT_EQ(arr.at(Key(4u)), Val(5u)); + ASSERT_EQ(arr.at(Key(3u)), Val(8u)); + ASSERT_EQ(arr.at(Key(1u)), Val(7u)); } } @@ -95,15 +95,15 @@ Array arr; // non-const versions - ASSERT_EQ(&arr.front(), &arr[Key(0)]); - ASSERT_EQ(&arr.back(), &arr[Key(9)]); - ASSERT_EQ(arr.data(), &arr[Key(0)]); + ASSERT_EQ(&arr.front(), &arr[Key(0u)]); + ASSERT_EQ(&arr.back(), &arr[Key(9u)]); + ASSERT_EQ(arr.data(), &arr[Key(0u)]); // const versions const Array& constArr = arr; - ASSERT_EQ(&constArr.front(), &constArr[Key(0)]); - ASSERT_EQ(&constArr.back(), &constArr[Key(9)]); - ASSERT_EQ(constArr.data(), &constArr[Key(0)]); + ASSERT_EQ(&constArr.front(), &constArr[Key(0u)]); + ASSERT_EQ(&constArr.back(), &constArr[Key(9u)]); + ASSERT_EQ(constArr.data(), &constArr[Key(0u)]); } // Name "*DeathTest" per https://google.github.io/googletest/advanced.html#death-test-naming @@ -118,12 +118,12 @@ } Array arr; - EXPECT_DEATH(arr[Key(10)], ""); - EXPECT_DEATH(arr.at(Key(10)), ""); + EXPECT_DEATH(arr[Key(10u)], ""); + EXPECT_DEATH(arr.at(Key(10u)), ""); const Array& constArr = arr; - EXPECT_DEATH(constArr[Key(10)], ""); - EXPECT_DEATH(constArr.at(Key(10)), ""); + EXPECT_DEATH(constArr[Key(10u)], ""); + EXPECT_DEATH(constArr.at(Key(10u)), ""); } // If the index/size is 64-bit, it needs to be narrowed to size_t. Verify that's checked correctly. @@ -138,11 +138,11 @@ ityp::array<Key64, Val, 10> vec; - vec[Key64(9)]; + vec[Key64(9u)]; // Regular out-of-bounds. - EXPECT_DEATH(vec[Key64(10)], ""); + EXPECT_DEATH(vec[Key64(10u)], ""); - vec[Key64(0)]; + vec[Key64(0u)]; // If this were cast to a 32-bit size_t without a check, it would be in-bounds. EXPECT_DEATH(vec[kHugeKey64], ""); }
diff --git a/src/dawn/tests/unittests/ITypBitsetTests.cpp b/src/dawn/tests/unittests/ITypBitsetTests.cpp index 1261320..a319bd0 100644 --- a/src/dawn/tests/unittests/ITypBitsetTests.cpp +++ b/src/dawn/tests/unittests/ITypBitsetTests.cpp
@@ -45,15 +45,15 @@ struct ConstexprTest { static constexpr Bitset kBitset = {1 << 0 | 1 << 3 | 1 << 7 | 1 << 8}; - static_assert(kBitset[Key(0)] == true); - static_assert(kBitset[Key(1)] == false); - static_assert(kBitset[Key(2)] == false); - static_assert(kBitset[Key(3)] == true); - static_assert(kBitset[Key(4)] == false); - static_assert(kBitset[Key(5)] == false); - static_assert(kBitset[Key(6)] == false); - static_assert(kBitset[Key(7)] == true); - static_assert(kBitset[Key(8)] == true); + static_assert(kBitset[Key(0u)] == true); + static_assert(kBitset[Key(1u)] == false); + static_assert(kBitset[Key(2u)] == false); + static_assert(kBitset[Key(3u)] == true); + static_assert(kBitset[Key(4u)] == false); + static_assert(kBitset[Key(5u)] == false); + static_assert(kBitset[Key(6u)] == false); + static_assert(kBitset[Key(7u)] == true); + static_assert(kBitset[Key(8u)] == true); static_assert(kBitset.size() == 9); }; @@ -98,16 +98,16 @@ Bitset bits; ExpectBits(bits, {}); - bits[Key(2)] = true; - bits[Key(4)] = false; - bits.set(Key(1)); - bits.set(Key(7), true); - bits.set(Key(8), false); + bits[Key(2u)] = true; + bits[Key(4u)] = false; + bits.set(Key(1u)); + bits.set(Key(7u), true); + bits.set(Key(8u), false); ExpectBits(bits, {1, 2, 7}); - bits.reset(Key(2)); - bits.reset(Key(7)); + bits.reset(Key(2u)); + bits.reset(Key(7u)); ExpectBits(bits, {1}); } @@ -116,10 +116,10 @@ Bitset bits = {1 << 1 | 1 << 2 | 1 << 7}; ExpectBits(bits, {1, 2, 7}); - bits.flip(Key(4)); - bits.flip(Key(1)); // false - bits.flip(Key(6)); - bits.flip(Key(5)); + bits.flip(Key(4u)); + bits.flip(Key(1u)); // false + bits.flip(Key(6u)); + bits.flip(Key(5u)); ExpectBits(bits, {2, 4, 5, 6, 7}); bits.flip(); @@ -139,7 +139,7 @@ ASSERT_TRUE(bits.any()); ASSERT_FALSE(bits.none()); - for (Key i(0); i < Key(9); ++i) { + for (Key i(0u); i < Key(9u); ++i) { ASSERT_TRUE(bits[i]); } @@ -150,7 +150,7 @@ ASSERT_FALSE(bits.any()); ASSERT_TRUE(bits.none()); - for (Key i(0); i < Key(9); ++i) { + for (Key i(0u); i < Key(9u); ++i) { ASSERT_FALSE(bits[i]); } } @@ -263,10 +263,10 @@ // Simple iterator test. TEST_F(ITypBitsetIteratorTest, Iterator) { std::set<IntegerT> originalValues; - originalValues.insert(IntegerT(2)); - originalValues.insert(IntegerT(6)); - originalValues.insert(IntegerT(8)); - originalValues.insert(IntegerT(35)); + originalValues.insert(IntegerT(2u)); + originalValues.insert(IntegerT(6u)); + originalValues.insert(IntegerT(8u)); + originalValues.insert(IntegerT(35u)); for (IntegerT value : originalValues) { mStateBits.set(value); @@ -297,15 +297,15 @@ TEST_F(ITypBitsetIteratorTest, NonLValueBitset) { ityp::bitset<IntegerT, 40> otherBits; - mStateBits.set(IntegerT(1)); - mStateBits.set(IntegerT(2)); - mStateBits.set(IntegerT(3)); - mStateBits.set(IntegerT(4)); + mStateBits.set(IntegerT(1u)); + mStateBits.set(IntegerT(2u)); + mStateBits.set(IntegerT(3u)); + mStateBits.set(IntegerT(4u)); - otherBits.set(IntegerT(0)); - otherBits.set(IntegerT(1)); - otherBits.set(IntegerT(3)); - otherBits.set(IntegerT(5)); + otherBits.set(IntegerT(0u)); + otherBits.set(IntegerT(1u)); + otherBits.set(IntegerT(3u)); + otherBits.set(IntegerT(5u)); std::set<IntegerT> seenBits;
diff --git a/src/dawn/tests/unittests/ITypSpanTests.cpp b/src/dawn/tests/unittests/ITypSpanTests.cpp index 71c0f27..f1377f8 100644 --- a/src/dawn/tests/unittests/ITypSpanTests.cpp +++ b/src/dawn/tests/unittests/ITypSpanTests.cpp
@@ -47,13 +47,13 @@ std::array<Val, 10> arr; Span span(arr.data(), Key(arr.size())); { - span[Key(2)] = Val(5); - span[Key(1)] = Val(9); - span[Key(9)] = Val(2); + span[Key(2u)] = Val(5u); + span[Key(1u)] = Val(9u); + span[Key(9u)] = Val(2u); - ASSERT_EQ(span[Key(2)], Val(5)); - ASSERT_EQ(span[Key(1)], Val(9)); - ASSERT_EQ(span[Key(9)], Val(2)); + ASSERT_EQ(span[Key(2u)], Val(5u)); + ASSERT_EQ(span[Key(1u)], Val(9u)); + ASSERT_EQ(span[Key(9u)], Val(2u)); } } @@ -81,20 +81,20 @@ Span span(arr.data(), Key(arr.size())); // non-const versions - ASSERT_EQ(&*span.begin(), &span[Key(0)]); - DAWN_UNSAFE_TODO(ASSERT_EQ(&*span.end(), &span[Key(0)] + static_cast<size_t>(span.size()))); - ASSERT_EQ(&span.front(), &span[Key(0)]); - ASSERT_EQ(&span.back(), &span[Key(9)]); - ASSERT_EQ(span.data(), &span[Key(0)]); + ASSERT_EQ(&*span.begin(), &span[Key(0u)]); + DAWN_UNSAFE_TODO(ASSERT_EQ(&*span.end(), &span[Key(0u)] + static_cast<size_t>(span.size()))); + ASSERT_EQ(&span.front(), &span[Key(0u)]); + ASSERT_EQ(&span.back(), &span[Key(9u)]); + ASSERT_EQ(span.data(), &span[Key(0u)]); // const versions const Span& constSpan = span; - ASSERT_EQ(&*constSpan.begin(), &constSpan[Key(0)]); + ASSERT_EQ(&*constSpan.begin(), &constSpan[Key(0u)]); DAWN_UNSAFE_TODO( - ASSERT_EQ(&*constSpan.end(), &constSpan[Key(0)] + static_cast<size_t>(constSpan.size()))); - ASSERT_EQ(&constSpan.front(), &constSpan[Key(0)]); - ASSERT_EQ(&constSpan.back(), &constSpan[Key(9)]); - ASSERT_EQ(constSpan.data(), &constSpan[Key(0)]); + ASSERT_EQ(&*constSpan.end(), &constSpan[Key(0u)] + static_cast<size_t>(constSpan.size()))); + ASSERT_EQ(&constSpan.front(), &constSpan[Key(0u)]); + ASSERT_EQ(&constSpan.back(), &constSpan[Key(9u)]); + ASSERT_EQ(constSpan.data(), &constSpan[Key(0u)]); } // Test the utility SpanFromUntyped @@ -104,15 +104,15 @@ Val* values = nullptr; Span span = ityp::SpanFromUntyped<Key>(values, 0); ASSERT_EQ(nullptr, span.data()); - ASSERT_EQ(Key(0), span.size()); + ASSERT_EQ(Key(0u), span.size()); } // Test creating a one element span. { - Val value = Val(25); + Val value = Val(25u); Span span = ityp::SpanFromUntyped<Key>(&value, 1); ASSERT_EQ(&value, span.data()); - ASSERT_EQ(Key(1), span.size()); - ASSERT_EQ(value, span[Key(0)]); + ASSERT_EQ(Key(1u), span.size()); + ASSERT_EQ(value, span[Key(0u)]); } // Test creating a multi-element span. { @@ -137,10 +137,10 @@ std::array<Val, 10> arr; Span span(arr.data(), Key(arr.size())); - EXPECT_DEATH(span[Key(10)], ""); + EXPECT_DEATH(span[Key(10u)], ""); const Span& constSpan = span; - EXPECT_DEATH(constSpan[Key(10)], ""); + EXPECT_DEATH(constSpan[Key(10u)], ""); } // If the index/size is 64-bit, it needs to be narrowed to size_t. Verify that's checked correctly. @@ -156,11 +156,11 @@ std::array<Val, 10> arr; ityp::span<Key64, Val> span(arr.data(), Key64(arr.size())); - span[Key64(9)]; + span[Key64(9u)]; // Regular out-of-bounds. - EXPECT_DEATH(span[Key64(10)], ""); + EXPECT_DEATH(span[Key64(10u)], ""); - span[Key64(0)]; + span[Key64(0u)]; // If this were cast to a 32-bit size_t without a check, it would be in-bounds. EXPECT_DEATH(span[kHugeKey64], ""); }
diff --git a/src/dawn/tests/unittests/ITypStackVecTests.cpp b/src/dawn/tests/unittests/ITypStackVecTests.cpp index 880a8a6..4d042e5 100644 --- a/src/dawn/tests/unittests/ITypStackVecTests.cpp +++ b/src/dawn/tests/unittests/ITypStackVecTests.cpp
@@ -47,16 +47,16 @@ // Default constructor initializes to 0 { StackVec vec; - ASSERT_EQ(vec.size(), Key(0)); + ASSERT_EQ(vec.size(), Key(0u)); } // Size constructor initializes contents to 0 { - StackVec vec(Key(10)); - ASSERT_EQ(vec.size(), Key(10)); + StackVec vec(Key(10u)); + ASSERT_EQ(vec.size(), Key(10u)); - for (Key i(0); i < Key(10); ++i) { - ASSERT_EQ(vec[i], Val(0)); + for (Key i(0u); i < Key(10u); ++i) { + ASSERT_EQ(vec[i], Val(0u)); } } } @@ -72,11 +72,11 @@ GTEST_SKIP(); } - StackVec vec(Key(10)); - EXPECT_DEATH(vec[Key(10)], ""); + StackVec vec(Key(10u)); + EXPECT_DEATH(vec[Key(10u)], ""); const StackVec& constVec = vec; - EXPECT_DEATH(constVec[Key(10)], ""); + EXPECT_DEATH(constVec[Key(10u)], ""); } // If the index/size is 64-bit, it needs to be narrowed to size_t. Verify that's checked correctly. @@ -87,18 +87,18 @@ } using Key64 = TypedInteger<struct Key64T, uint64_t>; - static constexpr Key64 kHugeKey64{0x1000'0000'0000'0000}; + static constexpr Key64 kHugeKey64{0x1000'0000'0000'0000u}; // Crash either due to OOM (on 64-bit) or due to narrowing (on 32-bit). EXPECT_DEATH((ityp::stack_vec<Key64, Val, 20>(kHugeKey64)), ""); - ityp::stack_vec<Key64, Val, 20> vec(Key64(10)); + ityp::stack_vec<Key64, Val, 20> vec(Key64(10u)); - vec[Key64(9)]; + vec[Key64(9u)]; // Regular out-of-bounds. - EXPECT_DEATH(vec[Key64(10)], ""); + EXPECT_DEATH(vec[Key64(10u)], ""); - vec[Key64(0)]; + vec[Key64(0u)]; // If this were cast to a 32-bit size_t without a check, it would be in-bounds. EXPECT_DEATH(vec[kHugeKey64], "");
diff --git a/src/dawn/tests/unittests/ITypVectorTests.cpp b/src/dawn/tests/unittests/ITypVectorTests.cpp index 145f830..a1474ef 100644 --- a/src/dawn/tests/unittests/ITypVectorTests.cpp +++ b/src/dawn/tests/unittests/ITypVectorTests.cpp
@@ -47,36 +47,36 @@ // Default constructor initializes to 0 { Vector vec; - ASSERT_EQ(vec.size(), Key(0)); + ASSERT_EQ(vec.size(), Key(0u)); } // Size constructor initializes contents to 0 { - Vector vec(Key(10)); - ASSERT_EQ(vec.size(), Key(10)); + Vector vec(Key(10u)); + ASSERT_EQ(vec.size(), Key(10u)); - for (Key i(0); i < Key(10); ++i) { - ASSERT_EQ(vec[i], Val(0)); + for (Key i(0u); i < Key(10u); ++i) { + ASSERT_EQ(vec[i], Val(0u)); } } // Size and initial value constructor initializes contents to the inital value { - Vector vec(Key(10), Val(7)); - ASSERT_EQ(vec.size(), Key(10)); + Vector vec(Key(10u), Val(7u)); + ASSERT_EQ(vec.size(), Key(10u)); - for (Key i(0); i < Key(10); ++i) { - ASSERT_EQ(vec[i], Val(7)); + for (Key i(0u); i < Key(10u); ++i) { + ASSERT_EQ(vec[i], Val(7u)); } } // Initializer list constructor { Vector vec = {Val(2u), Val(8u), Val(1u)}; - ASSERT_EQ(vec.size(), Key(3)); - ASSERT_EQ(vec[Key(0)], Val(2)); - ASSERT_EQ(vec[Key(1)], Val(8)); - ASSERT_EQ(vec[Key(2)], Val(1)); + ASSERT_EQ(vec.size(), Key(3u)); + ASSERT_EQ(vec[Key(0u)], Val(2u)); + ASSERT_EQ(vec[Key(1u)], Val(8u)); + ASSERT_EQ(vec[Key(2u)], Val(1u)); } } @@ -87,15 +87,15 @@ Vector rhs = {Val(2u), Val(8u), Val(1u)}; Vector vec(rhs); - ASSERT_EQ(vec.size(), Key(3)); - ASSERT_EQ(vec[Key(0)], Val(2)); - ASSERT_EQ(vec[Key(1)], Val(8)); - ASSERT_EQ(vec[Key(2)], Val(1)); + ASSERT_EQ(vec.size(), Key(3u)); + ASSERT_EQ(vec[Key(0u)], Val(2u)); + ASSERT_EQ(vec[Key(1u)], Val(8u)); + ASSERT_EQ(vec[Key(2u)], Val(1u)); - ASSERT_EQ(rhs.size(), Key(3)); - ASSERT_EQ(rhs[Key(0)], Val(2)); - ASSERT_EQ(rhs[Key(1)], Val(8)); - ASSERT_EQ(rhs[Key(2)], Val(1)); + ASSERT_EQ(rhs.size(), Key(3u)); + ASSERT_EQ(rhs[Key(0u)], Val(2u)); + ASSERT_EQ(rhs[Key(1u)], Val(8u)); + ASSERT_EQ(rhs[Key(2u)], Val(1u)); } // Test the copy assignment @@ -103,15 +103,15 @@ Vector rhs = {Val(2u), Val(8u), Val(1u)}; Vector vec = rhs; - ASSERT_EQ(vec.size(), Key(3)); - ASSERT_EQ(vec[Key(0)], Val(2)); - ASSERT_EQ(vec[Key(1)], Val(8)); - ASSERT_EQ(vec[Key(2)], Val(1)); + ASSERT_EQ(vec.size(), Key(3u)); + ASSERT_EQ(vec[Key(0u)], Val(2u)); + ASSERT_EQ(vec[Key(1u)], Val(8u)); + ASSERT_EQ(vec[Key(2u)], Val(1u)); - ASSERT_EQ(rhs.size(), Key(3)); - ASSERT_EQ(rhs[Key(0)], Val(2)); - ASSERT_EQ(rhs[Key(1)], Val(8)); - ASSERT_EQ(rhs[Key(2)], Val(1)); + ASSERT_EQ(rhs.size(), Key(3u)); + ASSERT_EQ(rhs[Key(0u)], Val(2u)); + ASSERT_EQ(rhs[Key(1u)], Val(8u)); + ASSERT_EQ(rhs[Key(2u)], Val(1u)); } } @@ -122,10 +122,10 @@ Vector rhs = {Val(2u), Val(8u), Val(1u)}; Vector vec(std::move(rhs)); - ASSERT_EQ(vec.size(), Key(3)); - ASSERT_EQ(vec[Key(0)], Val(2)); - ASSERT_EQ(vec[Key(1)], Val(8)); - ASSERT_EQ(vec[Key(2)], Val(1)); + ASSERT_EQ(vec.size(), Key(3u)); + ASSERT_EQ(vec[Key(0u)], Val(2u)); + ASSERT_EQ(vec[Key(1u)], Val(8u)); + ASSERT_EQ(vec[Key(2u)], Val(1u)); } // Test the move assignment @@ -133,39 +133,39 @@ Vector rhs = {Val(2u), Val(8u), Val(1u)}; Vector vec = std::move(rhs); - ASSERT_EQ(vec.size(), Key(3)); - ASSERT_EQ(vec[Key(0)], Val(2)); - ASSERT_EQ(vec[Key(1)], Val(8)); - ASSERT_EQ(vec[Key(2)], Val(1)); + ASSERT_EQ(vec.size(), Key(3u)); + ASSERT_EQ(vec[Key(0u)], Val(2u)); + ASSERT_EQ(vec[Key(1u)], Val(8u)); + ASSERT_EQ(vec[Key(2u)], Val(1u)); } } // Test that values can be set at an index and retrieved from the same index. TEST_F(ITypVectorTest, Indexing) { - Vector vec(Key(10)); + Vector vec(Key(10u)); { - vec[Key(2)] = Val(5); - vec[Key(1)] = Val(9); - vec[Key(9)] = Val(2); + vec[Key(2u)] = Val(5u); + vec[Key(1u)] = Val(9u); + vec[Key(9u)] = Val(2u); - ASSERT_EQ(vec[Key(2)], Val(5)); - ASSERT_EQ(vec[Key(1)], Val(9)); - ASSERT_EQ(vec[Key(9)], Val(2)); + ASSERT_EQ(vec[Key(2u)], Val(5u)); + ASSERT_EQ(vec[Key(1u)], Val(9u)); + ASSERT_EQ(vec[Key(9u)], Val(2u)); } { - vec.at(Key(4)) = Val(5); - vec.at(Key(3)) = Val(8); - vec.at(Key(1)) = Val(7); + vec.at(Key(4u)) = Val(5u); + vec.at(Key(3u)) = Val(8u); + vec.at(Key(1u)) = Val(7u); - ASSERT_EQ(vec.at(Key(4)), Val(5)); - ASSERT_EQ(vec.at(Key(3)), Val(8)); - ASSERT_EQ(vec.at(Key(1)), Val(7)); + ASSERT_EQ(vec.at(Key(4u)), Val(5u)); + ASSERT_EQ(vec.at(Key(3u)), Val(8u)); + ASSERT_EQ(vec.at(Key(1u)), Val(7u)); } } // Test that the vector can be iterated in order with a range-based for loop TEST_F(ITypVectorTest, RangeBasedIteration) { - Vector vec(Key(10)); + Vector vec(Key(10u)); // Assign in a non-const range-based for loop uint32_t i = 0; @@ -182,51 +182,51 @@ // Test that begin/end/front/back/data return pointers/references to the correct elements. TEST_F(ITypVectorTest, BeginEndFrontBackData) { - Vector vec(Key(10)); + Vector vec(Key(10u)); // non-const versions - ASSERT_EQ(&vec.front(), &vec[Key(0)]); - ASSERT_EQ(&vec.back(), &vec[Key(9)]); - ASSERT_EQ(vec.data(), &vec[Key(0)]); + ASSERT_EQ(&vec.front(), &vec[Key(0u)]); + ASSERT_EQ(&vec.back(), &vec[Key(9u)]); + ASSERT_EQ(vec.data(), &vec[Key(0u)]); // const versions const Vector& constVec = vec; - ASSERT_EQ(&constVec.front(), &constVec[Key(0)]); - ASSERT_EQ(&constVec.back(), &constVec[Key(9)]); - ASSERT_EQ(constVec.data(), &constVec[Key(0)]); + ASSERT_EQ(&constVec.front(), &constVec[Key(0u)]); + ASSERT_EQ(&constVec.back(), &constVec[Key(9u)]); + ASSERT_EQ(constVec.data(), &constVec[Key(0u)]); } // Special case to make sure that operator[] works for ityp::vector<I, bool> as vector<bool> doesn't // return a bool& for these (so that vector<bool> may use a bitfield internally). TEST_F(ITypVectorTest, BoolVectorIndexing) { { - ityp::vector<Key, bool> vec(Key(5)); + ityp::vector<Key, bool> vec(Key(5u)); const auto& const_vec = vec; - vec[Key(2)] = true; - vec[Key(1)] = true; - vec[Key(4)] = true; + vec[Key(2u)] = true; + vec[Key(1u)] = true; + vec[Key(4u)] = true; - ASSERT_EQ(const_vec[Key(0)], false); - ASSERT_EQ(const_vec[Key(1)], true); - ASSERT_EQ(const_vec[Key(2)], true); - ASSERT_EQ(const_vec[Key(3)], false); - ASSERT_EQ(const_vec[Key(4)], true); + ASSERT_EQ(const_vec[Key(0u)], false); + ASSERT_EQ(const_vec[Key(1u)], true); + ASSERT_EQ(const_vec[Key(2u)], true); + ASSERT_EQ(const_vec[Key(3u)], false); + ASSERT_EQ(const_vec[Key(4u)], true); } { - ityp::vector<Key, bool> vec(Key(5)); + ityp::vector<Key, bool> vec(Key(5u)); const auto& const_vec = vec; - vec.at(Key(2)) = true; - vec.at(Key(1)) = true; - vec.at(Key(4)) = true; + vec.at(Key(2u)) = true; + vec.at(Key(1u)) = true; + vec.at(Key(4u)) = true; - ASSERT_EQ(const_vec.at(Key(0)), false); - ASSERT_EQ(const_vec.at(Key(1)), true); - ASSERT_EQ(const_vec.at(Key(2)), true); - ASSERT_EQ(const_vec.at(Key(3)), false); - ASSERT_EQ(const_vec.at(Key(4)), true); + ASSERT_EQ(const_vec.at(Key(0u)), false); + ASSERT_EQ(const_vec.at(Key(1u)), true); + ASSERT_EQ(const_vec.at(Key(2u)), true); + ASSERT_EQ(const_vec.at(Key(3u)), false); + ASSERT_EQ(const_vec.at(Key(4u)), true); } } @@ -241,15 +241,15 @@ GTEST_SKIP(); } - Vector vec(Key(10), Val(7)); - vec[Key(9)]; - EXPECT_DEATH(vec[Key(10)], ""); - EXPECT_DEATH(vec.at(Key(10)), ""); + Vector vec(Key(10u), Val(7u)); + vec[Key(9u)]; + EXPECT_DEATH(vec[Key(10u)], ""); + EXPECT_DEATH(vec.at(Key(10u)), ""); const Vector& constVec = vec; - constVec[Key(9)]; - EXPECT_DEATH(constVec[Key(10)], ""); - EXPECT_DEATH(constVec.at(Key(10)), ""); + constVec[Key(9u)]; + EXPECT_DEATH(constVec[Key(10u)], ""); + EXPECT_DEATH(constVec.at(Key(10u)), ""); } // If the index/size is 64-bit, it needs to be narrowed to size_t. Verify that's checked correctly. @@ -260,24 +260,24 @@ } using Key64 = TypedInteger<struct Key64T, uint64_t>; - static constexpr Key64 kHugeKey64{0x1000'0000'0000'0000}; + static constexpr Key64 kHugeKey64{0x1000'0000'0000'0000u}; // Crash either due to OOM (on 64-bit) or due to narrowing (on 32-bit). EXPECT_DEATH((ityp::vector<Key64, Val>(kHugeKey64)), ""); - EXPECT_DEATH((ityp::vector<Key64, Val>(kHugeKey64, Val(7))), ""); + EXPECT_DEATH((ityp::vector<Key64, Val>(kHugeKey64, Val(7u))), ""); - ityp::vector<Key64, Val> vec(Key64(10), Val(7)); + ityp::vector<Key64, Val> vec(Key64(10u), Val(7u)); - vec[Key64(9)]; + vec[Key64(9u)]; // Regular out-of-bounds. - EXPECT_DEATH(vec[Key64(10)], ""); + EXPECT_DEATH(vec[Key64(10u)], ""); - vec[Key64(0)]; + vec[Key64(0u)]; // If this were cast to a 32-bit size_t without a check, it would be in-bounds. EXPECT_DEATH(vec[kHugeKey64], ""); EXPECT_DEATH(vec.resize(kHugeKey64), ""); - EXPECT_DEATH(vec.resize(kHugeKey64, Val(7)), ""); + EXPECT_DEATH(vec.resize(kHugeKey64, Val(7u)), ""); EXPECT_DEATH(vec.reserve(kHugeKey64), ""); }
diff --git a/src/dawn/tests/unittests/LRUCacheTests.cpp b/src/dawn/tests/unittests/LRUCacheTests.cpp index 3e8d370..88cffbe 100644 --- a/src/dawn/tests/unittests/LRUCacheTests.cpp +++ b/src/dawn/tests/unittests/LRUCacheTests.cpp
@@ -93,7 +93,7 @@ TEST(LRUCache, ZeroSizedCache) { TestCache cache(0); - CacheKey key(1); + CacheKey key(1u); uint32_t cacheId; { // The constructed values should be evicted immediately. @@ -117,13 +117,13 @@ uint32_t cacheId; { - CacheKey key(1); + CacheKey key(1u); CacheValue value = cache.GetOrCreateNoError(key); cacheId = value.mId; } { - CacheKey key(1); + CacheKey key(1u); CacheValue value = cache.GetOrCreateNoError(key); // A new CacheValue should be returned. @@ -145,7 +145,7 @@ // Calling GetOrCreate with an existing key won't cause a cache eviction { - CacheKey key(1); + CacheKey key(1u); EXPECT_CALL(cache, EvictedFromCache(testing::_)).Times(0); cache.GetOrCreateNoError(key); } @@ -160,7 +160,7 @@ // The oldest value in the cache (key 0) should have been the one evicted, // as evidenced by us receiving a new value when querying it again. { - CacheKey key(0); + CacheKey key(0u); EXPECT_CALL(cache, EvictedFromCache(testing::_)); auto value = cache.GetOrCreateNoError(key); EXPECT_NE(value.mId, keyIds[0]); @@ -169,7 +169,7 @@ // The value for key 1 should not have been the one evicted after the last // call, because it was queried more recently than the other keys. { - CacheKey key(1); + CacheKey key(1u); EXPECT_CALL(cache, EvictedFromCache(testing::_)).Times(0); auto value = cache.GetOrCreateNoError(key); EXPECT_EQ(value.mId, keyIds[1]); @@ -197,7 +197,7 @@ // Calling GetOrCreate with a previously created key should return a new // value and cause no evictions { - CacheKey key(0); + CacheKey key(0u); EXPECT_CALL(cache, EvictedFromCache(testing::_)).Times(0); auto value = cache.GetOrCreateNoError(key); EXPECT_NE(value.mId, keyIds[0]);
diff --git a/src/dawn/tests/unittests/MutexProtectedTests.cpp b/src/dawn/tests/unittests/MutexProtectedTests.cpp index a78b614..cadf4e6 100644 --- a/src/dawn/tests/unittests/MutexProtectedTests.cpp +++ b/src/dawn/tests/unittests/MutexProtectedTests.cpp
@@ -236,7 +236,7 @@ TEST(MutexCondVarProtectedTest, WaitForTimeout) { auto counter = MutexCondVarProtected<CounterT>(); counter.Use([](auto c) { - EXPECT_FALSE(c.WaitFor(Nanoseconds(5), [](auto& x) { return x.Get() == 1; })); + EXPECT_FALSE(c.WaitFor(Nanoseconds(5u), [](auto& x) { return x.Get() == 1; })); }); }
diff --git a/src/dawn/tests/unittests/RingBufferAllocatorTests.cpp b/src/dawn/tests/unittests/RingBufferAllocatorTests.cpp index 5a1a464..824be53 100644 --- a/src/dawn/tests/unittests/RingBufferAllocatorTests.cpp +++ b/src/dawn/tests/unittests/RingBufferAllocatorTests.cpp
@@ -45,15 +45,15 @@ ASSERT_EQ(allocator.GetSize(), sizeInBytes); // Ensure failure upon sub-allocating an oversized request. - ASSERT_EQ(allocator.Allocate(sizeInBytes + 1, ExecutionSerial(0)), + ASSERT_EQ(allocator.Allocate(sizeInBytes + 1, ExecutionSerial(0u)), RingBufferAllocator::kInvalidOffset); // Fill the entire buffer with two requests of equal size. - ASSERT_EQ(allocator.Allocate(sizeInBytes / 2, ExecutionSerial(1)), 0u); - ASSERT_EQ(allocator.Allocate(sizeInBytes / 2, ExecutionSerial(2)), 32000u); + ASSERT_EQ(allocator.Allocate(sizeInBytes / 2, ExecutionSerial(1u)), 0u); + ASSERT_EQ(allocator.Allocate(sizeInBytes / 2, ExecutionSerial(2u)), 32000u); // Ensure the buffer is full. - ASSERT_EQ(allocator.Allocate(1, ExecutionSerial(3)), RingBufferAllocator::kInvalidOffset); + ASSERT_EQ(allocator.Allocate(1, ExecutionSerial(3u)), RingBufferAllocator::kInvalidOffset); } // Tests that several ringbuffer allocations do not fail. @@ -64,7 +64,7 @@ RingBufferAllocator allocator(maxNumOfFrames * frameSizeInBytes); size_t offset = 0; - for (ExecutionSerial i(0); i < ExecutionSerial(maxNumOfFrames); ++i) { + for (ExecutionSerial i(0u); i < ExecutionSerial(maxNumOfFrames); ++i) { offset = allocator.Allocate(frameSizeInBytes, i); ASSERT_EQ(offset, uint64_t(i) * frameSizeInBytes); } @@ -79,22 +79,22 @@ // F1 // [xxxx|--------] - size_t offset = allocator.Allocate(frameSizeInBytes, ExecutionSerial(1)); + size_t offset = allocator.Allocate(frameSizeInBytes, ExecutionSerial(1u)); // F1 F2 // [xxxx|xxxx|----] - offset = allocator.Allocate(frameSizeInBytes, ExecutionSerial(2)); + offset = allocator.Allocate(frameSizeInBytes, ExecutionSerial(2u)); // F1 F2 // [xxxx|xxxxxxxx] - offset = allocator.Allocate(frameSizeInBytes, ExecutionSerial(2)); + offset = allocator.Allocate(frameSizeInBytes, ExecutionSerial(2u)); ASSERT_EQ(offset, 8u); ASSERT_EQ(allocator.GetUsedSize(), frameSizeInBytes * 3); - allocator.Deallocate(ExecutionSerial(2)); + allocator.Deallocate(ExecutionSerial(2u)); ASSERT_EQ(allocator.GetUsedSize(), 0u); EXPECT_TRUE(allocator.Empty()); @@ -108,8 +108,8 @@ RingBufferAllocator allocator(maxNumOfFrames * frameSizeInBytes); // Sub-alloc the first eight frames. - ExecutionSerial serial(0); - while (serial < ExecutionSerial(8)) { + ExecutionSerial serial(0u); + while (serial < ExecutionSerial(8u)) { allocator.Allocate(frameSizeInBytes, serial); serial++; } @@ -126,7 +126,7 @@ ASSERT_EQ(allocator.GetUsedSize(), frameSizeInBytes * 8); // Reclaim the first 3 frames. - allocator.Deallocate(ExecutionSerial(2)); + allocator.Deallocate(ExecutionSerial(2u)); // F4 F5 F6 F7 F8 // [------------|xxxx|xxxx|xxxx|xxxx|xxxx|--------] @@ -151,7 +151,7 @@ ASSERT_EQ(allocator.Allocate(frameSizeInBytes, serial), RingBufferAllocator::kInvalidOffset); // Reclaim the next two frames. - allocator.Deallocate(ExecutionSerial(4)); + allocator.Deallocate(ExecutionSerial(4u)); // F9 F4 F5 F6 F7 F8 // [xxxxxxxxxxxx|----|----|xxxx|xxxx|xxxx|xxxxxxxx] @@ -182,8 +182,8 @@ TEST(RingBufferAllocatorTests, RingBufferOverflow) { RingBufferAllocator allocator(std::numeric_limits<uint64_t>::max()); - ASSERT_EQ(allocator.Allocate(1, ExecutionSerial(1)), 0u); - ASSERT_EQ(allocator.Allocate(std::numeric_limits<uint64_t>::max(), ExecutionSerial(1)), + ASSERT_EQ(allocator.Allocate(1, ExecutionSerial(1u)), 0u); + ASSERT_EQ(allocator.Allocate(std::numeric_limits<uint64_t>::max(), ExecutionSerial(1u)), RingBufferAllocator::kInvalidOffset); }
diff --git a/src/dawn/tests/unittests/SerialMapTests.cpp b/src/dawn/tests/unittests/SerialMapTests.cpp index 13fefd8..4df701d 100644 --- a/src/dawn/tests/unittests/SerialMapTests.cpp +++ b/src/dawn/tests/unittests/SerialMapTests.cpp
@@ -186,8 +186,8 @@ using MySerialMap = SerialMap<MySerial, int>; MySerialMap map; - map.Enqueue(1, MySerial(0)); - map.Enqueue(2, MySerial(0)); + map.Enqueue(1, MySerial(0u)); + map.Enqueue(2, MySerial(0u)); std::vector<int> expectedValues = {1, 2}; for (int value : map.IterateAll()) {
diff --git a/src/dawn/tests/unittests/SerialQueueTests.cpp b/src/dawn/tests/unittests/SerialQueueTests.cpp index d120905..dc42ecd 100644 --- a/src/dawn/tests/unittests/SerialQueueTests.cpp +++ b/src/dawn/tests/unittests/SerialQueueTests.cpp
@@ -178,8 +178,8 @@ using MySerialQueue = SerialQueue<MySerial, int>; MySerialQueue queue; - queue.Enqueue(1, MySerial(0)); - queue.Enqueue(2, MySerial(0)); + queue.Enqueue(1, MySerial(0u)); + queue.Enqueue(2, MySerial(0u)); std::vector<int> expectedValues = {1, 2}; for (int value : queue.IterateAll()) {
diff --git a/src/dawn/tests/unittests/d3d12/CopySplitTests.cpp b/src/dawn/tests/unittests/d3d12/CopySplitTests.cpp index 4d48fc8..3f25589 100644 --- a/src/dawn/tests/unittests/d3d12/CopySplitTests.cpp +++ b/src/dawn/tests/unittests/d3d12/CopySplitTests.cpp
@@ -210,7 +210,7 @@ void ValidatePixelCount(const TextureSpec& textureSpec, const TextureCopySubresource& copySubresource) { const TypedTexelBlockInfo& blockInfo = textureSpec.blockInfo; - TexelCount totalCopiedTexels{0}; + TexelCount totalCopiedTexels{0u}; for (uint32_t i = 0; i < copySubresource.count; ++i) { const auto& copy = copySubresource.copies[i]; // TODO(425944899): Rework this function to work in blocks, not texels @@ -247,7 +247,7 @@ // a 3D texture copy region when we are copying the last row of each slice. We may // need to offset a lot rows and copy.bufferOffset.y may be big. if (dimension == wgpu::TextureDimension::e2D) { - ASSERT_LE(bufferOffset.y, BlockCount{1}); + ASSERT_LE(bufferOffset.y, BlockCount{1u}); } ASSERT_EQ(bufferOffset.z, 0_bc);
diff --git a/src/dawn/tests/unittests/native/CommandBufferEncodingTests.cpp b/src/dawn/tests/unittests/native/CommandBufferEncodingTests.cpp index 8ddbc74..a8b9499 100644 --- a/src/dawn/tests/unittests/native/CommandBufferEncodingTests.cpp +++ b/src/dawn/tests/unittests/native/CommandBufferEncodingTests.cpp
@@ -124,10 +124,10 @@ // Expect restored state. EXPECT_EQ(ToAPI(stateTracker->GetComputePipeline()), pipeline0.Get()); EXPECT_EQ(ToAPI(stateTracker->GetPipelineLayout()), pl0.Get()); - EXPECT_EQ(ToAPI(stateTracker->GetBindGroup(BindGroupIndex(0))), staticBG.Get()); - EXPECT_EQ(stateTracker->GetDynamicOffsets(BindGroupIndex(0)), emptyDynamicOffsets); - EXPECT_EQ(ToAPI(stateTracker->GetBindGroup(BindGroupIndex(1))), dynamicBG.Get()); - EXPECT_EQ(stateTracker->GetDynamicOffsets(BindGroupIndex(1)), singleDynamicOffset); + EXPECT_EQ(ToAPI(stateTracker->GetBindGroup(BindGroupIndex(0u))), staticBG.Get()); + EXPECT_EQ(stateTracker->GetDynamicOffsets(BindGroupIndex(0u)), emptyDynamicOffsets); + EXPECT_EQ(ToAPI(stateTracker->GetBindGroup(BindGroupIndex(1u))), dynamicBG.Get()); + EXPECT_EQ(stateTracker->GetDynamicOffsets(BindGroupIndex(1u)), singleDynamicOffset); // Dispatch again to check that the restored state can be used. // Also pass an indirect offset which should get replaced with the offset @@ -137,10 +137,10 @@ // Expect restored state. EXPECT_EQ(ToAPI(stateTracker->GetComputePipeline()), pipeline0.Get()); EXPECT_EQ(ToAPI(stateTracker->GetPipelineLayout()), pl0.Get()); - EXPECT_EQ(ToAPI(stateTracker->GetBindGroup(BindGroupIndex(0))), staticBG.Get()); - EXPECT_EQ(stateTracker->GetDynamicOffsets(BindGroupIndex(0)), emptyDynamicOffsets); - EXPECT_EQ(ToAPI(stateTracker->GetBindGroup(BindGroupIndex(1))), dynamicBG.Get()); - EXPECT_EQ(stateTracker->GetDynamicOffsets(BindGroupIndex(1)), singleDynamicOffset); + EXPECT_EQ(ToAPI(stateTracker->GetBindGroup(BindGroupIndex(0u))), staticBG.Get()); + EXPECT_EQ(stateTracker->GetDynamicOffsets(BindGroupIndex(0u)), emptyDynamicOffsets); + EXPECT_EQ(ToAPI(stateTracker->GetBindGroup(BindGroupIndex(1u))), dynamicBG.Get()); + EXPECT_EQ(stateTracker->GetDynamicOffsets(BindGroupIndex(1u)), singleDynamicOffset); // Change the pipeline pass.SetPipeline(pipeline1); @@ -154,10 +154,10 @@ // Expect restored state. EXPECT_EQ(ToAPI(stateTracker->GetComputePipeline()), pipeline1.Get()); EXPECT_EQ(ToAPI(stateTracker->GetPipelineLayout()), pl1.Get()); - EXPECT_EQ(ToAPI(stateTracker->GetBindGroup(BindGroupIndex(0))), dynamicBG.Get()); - EXPECT_EQ(stateTracker->GetDynamicOffsets(BindGroupIndex(0)), singleDynamicOffset); - EXPECT_EQ(ToAPI(stateTracker->GetBindGroup(BindGroupIndex(1))), staticBG.Get()); - EXPECT_EQ(stateTracker->GetDynamicOffsets(BindGroupIndex(1)), emptyDynamicOffsets); + EXPECT_EQ(ToAPI(stateTracker->GetBindGroup(BindGroupIndex(0u))), dynamicBG.Get()); + EXPECT_EQ(stateTracker->GetDynamicOffsets(BindGroupIndex(0u)), singleDynamicOffset); + EXPECT_EQ(ToAPI(stateTracker->GetBindGroup(BindGroupIndex(1u))), staticBG.Get()); + EXPECT_EQ(stateTracker->GetDynamicOffsets(BindGroupIndex(1u)), emptyDynamicOffsets); pass.End(); @@ -216,7 +216,7 @@ auto ExpectSetValidationBindGroup = [&](CommandIterator* commands) { auto* cmd = commands->NextCommand<SetBindGroupCmd>(); - ASSERT_EQ(cmd->index, BindGroupIndex(0)); + ASSERT_EQ(cmd->index, BindGroupIndex(0u)); ASSERT_NE(cmd->group.Get(), nullptr); ASSERT_EQ(cmd->dynamicOffsetCount, 0u); };
diff --git a/src/dawn/tests/unittests/native/StreamTests.cpp b/src/dawn/tests/unittests/native/StreamTests.cpp index 4b5dff8..c69e357 100644 --- a/src/dawn/tests/unittests/native/StreamTests.cpp +++ b/src/dawn/tests/unittests/native/StreamTests.cpp
@@ -392,13 +392,13 @@ // Test that ByteVectorSink serializes ityp::array as expected. TEST(SerializeTests, ItypArray) { const ityp::array<TypedIntegerForTest, TypedIntegerForTest, 4> input = { - TypedIntegerForTest(99), TypedIntegerForTest(4), TypedIntegerForTest(6), - TypedIntegerForTest(1)}; + TypedIntegerForTest(99u), TypedIntegerForTest(4u), TypedIntegerForTest(6u), + TypedIntegerForTest(1u)}; // Expect all values. ByteVectorSink expected; - StreamIn(&expected, TypedIntegerForTest(99), TypedIntegerForTest(4), TypedIntegerForTest(6), - TypedIntegerForTest(1)); + StreamIn(&expected, TypedIntegerForTest(99u), TypedIntegerForTest(4u), TypedIntegerForTest(6u), + TypedIntegerForTest(1u)); EXPECT_CACHE_KEY_EQ(input, expected); }
diff --git a/src/dawn/tests/white_box/D3D12DescriptorHeapTests.cpp b/src/dawn/tests/white_box/D3D12DescriptorHeapTests.cpp index 0cb2ae0..a8d8aa0 100644 --- a/src/dawn/tests/white_box/D3D12DescriptorHeapTests.cpp +++ b/src/dawn/tests/white_box/D3D12DescriptorHeapTests.cpp
@@ -189,7 +189,7 @@ wgpu::CommandBuffer commands = encoder.Finish(); queue.Submit(1, &commands); - EXPECT_EQ(allocator->GetShaderVisibleHeapSerialForTesting(), heapSerial + HeapVersionID(1)); + EXPECT_EQ(allocator->GetShaderVisibleHeapSerialForTesting(), heapSerial + HeapVersionID(1u)); } // Tests that a descriptor heap switch, which changes the current descriptor tables, in one type of @@ -431,7 +431,7 @@ wgpu::CommandBuffer commands = encoder.Finish(); queue.Submit(1, &commands); - EXPECT_EQ(allocator->GetShaderVisibleHeapSerialForTesting(), heapSerial + HeapVersionID(1)); + EXPECT_EQ(allocator->GetShaderVisibleHeapSerialForTesting(), heapSerial + HeapVersionID(1u)); } // Verify the shader visible sampler heaps does not switch over within a single submit when samplers @@ -611,7 +611,7 @@ wgpu::CommandBuffer commands = encoder.Finish(); queue.Submit(1, &commands); - EXPECT_EQ(allocator->GetShaderVisibleHeapSerialForTesting(), heapSerial + HeapVersionID(1)); + EXPECT_EQ(allocator->GetShaderVisibleHeapSerialForTesting(), heapSerial + HeapVersionID(1u)); } // Verify the shader visible sampler heap switches over within a single submit because bind group 0 @@ -750,7 +750,7 @@ wgpu::CommandBuffer commands = encoder.Finish(); queue.Submit(1, &commands); - EXPECT_EQ(allocator->GetShaderVisibleHeapSerialForTesting(), heapSerial + HeapVersionID(1)); + EXPECT_EQ(allocator->GetShaderVisibleHeapSerialForTesting(), heapSerial + HeapVersionID(1u)); } // Verify shader-visible heaps can be recycled for multiple submits. @@ -1786,14 +1786,16 @@ { wgpu::ResourceTable table = MakeResourceTable(heapSize - mImplicitDescriptorCount); draw(table); - EXPECT_EQ(allocator->GetShaderVisibleHeapSerialForTesting(), heapSerial + HeapVersionID(0)); + EXPECT_EQ(allocator->GetShaderVisibleHeapSerialForTesting(), + heapSerial + HeapVersionID(0u)); } // Make largest table { wgpu::ResourceTable table = MakeResourceTable(kMaxResourceTableSize - mImplicitDescriptorCount); draw(table); - EXPECT_EQ(allocator->GetShaderVisibleHeapSerialForTesting(), heapSerial + HeapVersionID(1)); + EXPECT_EQ(allocator->GetShaderVisibleHeapSerialForTesting(), + heapSerial + HeapVersionID(1u)); } } @@ -1854,7 +1856,7 @@ wgpu::CommandBuffer commands = encoder.Finish(); queue.Submit(1, &commands); - EXPECT_EQ(allocator->GetShaderVisibleHeapSerialForTesting(), heapSerial + HeapVersionID(1)); + EXPECT_EQ(allocator->GetShaderVisibleHeapSerialForTesting(), heapSerial + HeapVersionID(1u)); } DAWN_INSTANTIATE_TEST(D3D12ResourceTableDescriptorHeapTests, D3D12Backend(), );
diff --git a/src/dawn/tests/white_box/D3D12ResidencyTests.cpp b/src/dawn/tests/white_box/D3D12ResidencyTests.cpp index fa505b6..7e753a9 100644 --- a/src/dawn/tests/white_box/D3D12ResidencyTests.cpp +++ b/src/dawn/tests/white_box/D3D12ResidencyTests.cpp
@@ -410,7 +410,7 @@ // Check the heap serial to ensure the heap has switched. EXPECT_EQ(allocator->GetShaderVisibleHeapSerialForTesting(), - heapSerial + native::d3d12::HeapVersionID(1)); + heapSerial + native::d3d12::HeapVersionID(1u)); // Check that currrently bound ShaderVisibleHeap is locked resident. EXPECT_TRUE(allocator->IsShaderVisibleHeapLockedResidentForTesting());
diff --git a/src/utils/typed_integer.h b/src/utils/typed_integer.h index bc3df3b..dcb58d6 100644 --- a/src/utils/typed_integer.h +++ b/src/utils/typed_integer.h
@@ -100,12 +100,6 @@ requires kIsCastAlwaysInRange<Src, T> explicit constexpr TypedIntegerImpl(Src src) : mValue(static_cast<T>(src)) {} - // In consteval, we can allow narrowing casts because we can check the actual value at compile. - // TODO(crbug.com/515794394): Remove this due to issues with lambda type inference. - template <std::integral Src> - requires(!kIsCastAlwaysInRange<Src, T>) - explicit consteval TypedIntegerImpl(Src src) : mValue(checked_cast<T>(src)) {} - // Lossless conversion: TypedInteger -> primitive (cast) // If you need a lossy (narrowing) conversion, use (d)checked_cast. template <std::integral Dst> @@ -114,14 +108,6 @@ return static_cast<Dst>(this->mValue); } - // In consteval, we can allow narrowing casts because we can check the actual value at compile. - // TODO(crbug.com/515794394): Remove this due to issues with lambda type inference. - template <std::integral Dst> - requires(!kIsCastAlwaysInRange<T, Dst>) - explicit consteval operator Dst() const { - return checked_cast<Dst>(this->mValue); - } - // Same-tag TypedInteger comparison operators constexpr auto operator<=>(const TypedIntegerImpl& rhs) const = default;
diff --git a/src/utils/typed_integer_tests.cc b/src/utils/typed_integer_tests.cc index d66e59c..63acac9 100644 --- a/src/utils/typed_integer_tests.cc +++ b/src/utils/typed_integer_tests.cc
@@ -45,11 +45,11 @@ Signed svalue(2); EXPECT_EQ(static_cast<int32_t>(svalue), 2); - Unsigned uvalue(7); + Unsigned uvalue(7u); EXPECT_EQ(static_cast<uint32_t>(uvalue), 7u); static_assert(static_cast<int32_t>(Signed(3)) == 3); - static_assert(static_cast<uint32_t>(Unsigned(28)) == 28); + static_assert(static_cast<uint32_t>(Unsigned(28u)) == 28); } // Test that typed integers can be explicitly cast to other integral types @@ -105,27 +105,27 @@ // Test typed integer comparison operators TEST_F(TypedIntegerTest, Comparison) { - Unsigned value(8); + Unsigned value(8u); // Truthy usages of comparison operators - EXPECT_TRUE(value < Unsigned(9)); - EXPECT_TRUE(value <= Unsigned(9)); - EXPECT_TRUE(value <= Unsigned(8)); - EXPECT_TRUE(value == Unsigned(8)); - EXPECT_TRUE(value >= Unsigned(8)); - EXPECT_TRUE(value >= Unsigned(7)); - EXPECT_TRUE(value > Unsigned(7)); - EXPECT_TRUE(value != Unsigned(7)); + EXPECT_TRUE(value < Unsigned(9u)); + EXPECT_TRUE(value <= Unsigned(9u)); + EXPECT_TRUE(value <= Unsigned(8u)); + EXPECT_TRUE(value == Unsigned(8u)); + EXPECT_TRUE(value >= Unsigned(8u)); + EXPECT_TRUE(value >= Unsigned(7u)); + EXPECT_TRUE(value > Unsigned(7u)); + EXPECT_TRUE(value != Unsigned(7u)); // Falsy usages of comparison operators - EXPECT_FALSE(value >= Unsigned(9)); - EXPECT_FALSE(value > Unsigned(9)); - EXPECT_FALSE(value > Unsigned(8)); - EXPECT_FALSE(value != Unsigned(8)); - EXPECT_FALSE(value < Unsigned(8)); - EXPECT_FALSE(value < Unsigned(7)); - EXPECT_FALSE(value <= Unsigned(7)); - EXPECT_FALSE(value == Unsigned(7)); + EXPECT_FALSE(value >= Unsigned(9u)); + EXPECT_FALSE(value > Unsigned(9u)); + EXPECT_FALSE(value > Unsigned(8u)); + EXPECT_FALSE(value != Unsigned(8u)); + EXPECT_FALSE(value < Unsigned(8u)); + EXPECT_FALSE(value < Unsigned(7u)); + EXPECT_FALSE(value <= Unsigned(7u)); + EXPECT_FALSE(value == Unsigned(7u)); } TEST_F(TypedIntegerTest, Arithmetic) { @@ -179,22 +179,22 @@ // Unsigned addition { - Unsigned a(9); - Unsigned b(3); + Unsigned a(9u); + Unsigned b(3u); Unsigned c = a + b; - EXPECT_EQ(a, Unsigned(9)); - EXPECT_EQ(b, Unsigned(3)); - EXPECT_EQ(c, Unsigned(12)); + EXPECT_EQ(a, Unsigned(9u)); + EXPECT_EQ(b, Unsigned(3u)); + EXPECT_EQ(c, Unsigned(12u)); } // Unsigned subtraction { - Unsigned a(9); - Unsigned b(2); + Unsigned a(9u); + Unsigned b(2u); Unsigned c = a - b; - EXPECT_EQ(a, Unsigned(9)); - EXPECT_EQ(b, Unsigned(2)); - EXPECT_EQ(c, Unsigned(7)); + EXPECT_EQ(a, Unsigned(9u)); + EXPECT_EQ(b, Unsigned(2u)); + EXPECT_EQ(c, Unsigned(7u)); } // Negation @@ -217,12 +217,12 @@ // Unsigned multiplication { - Unsigned a(9); - Unsigned b(3); + Unsigned a(9u); + Unsigned b(3u); Unsigned c = a * b; - EXPECT_EQ(a, Unsigned(9)); - EXPECT_EQ(b, Unsigned(3)); - EXPECT_EQ(c, Unsigned(27)); + EXPECT_EQ(a, Unsigned(9u)); + EXPECT_EQ(b, Unsigned(3u)); + EXPECT_EQ(c, Unsigned(27u)); } // Signed division @@ -237,12 +237,12 @@ // Unsigned division { - Unsigned a(12); - Unsigned b(3); + Unsigned a(12u); + Unsigned b(3u); Unsigned c = a / b; - EXPECT_EQ(a, Unsigned(12)); - EXPECT_EQ(b, Unsigned(3)); - EXPECT_EQ(c, Unsigned(4)); + EXPECT_EQ(a, Unsigned(12u)); + EXPECT_EQ(b, Unsigned(3u)); + EXPECT_EQ(c, Unsigned(4u)); } // Signed modulo @@ -257,12 +257,12 @@ // Unsigned modulo { - Unsigned a(12); - Unsigned b(5); + Unsigned a(12u); + Unsigned b(5u); Unsigned c = a % b; - EXPECT_EQ(a, Unsigned(12)); - EXPECT_EQ(b, Unsigned(5)); - EXPECT_EQ(c, Unsigned(2)); + EXPECT_EQ(a, Unsigned(12u)); + EXPECT_EQ(b, Unsigned(5u)); + EXPECT_EQ(c, Unsigned(2u)); } } @@ -287,20 +287,20 @@ // Unsigned addition assignment { - Unsigned a(9); - Unsigned b(3); + Unsigned a(9u); + Unsigned b(3u); a += b; - EXPECT_EQ(a, Unsigned(12)); - EXPECT_EQ(b, Unsigned(3)); + EXPECT_EQ(a, Unsigned(12u)); + EXPECT_EQ(b, Unsigned(3u)); } // Unsigned subtraction assignment { - Unsigned a(9); - Unsigned b(2); + Unsigned a(9u); + Unsigned b(2u); a -= b; - EXPECT_EQ(a, Unsigned(7)); - EXPECT_EQ(b, Unsigned(2)); + EXPECT_EQ(a, Unsigned(7u)); + EXPECT_EQ(b, Unsigned(2u)); } // Signed multiplication assignment @@ -314,11 +314,11 @@ // Unsigned multiplication assignment { - Unsigned a(9); - Unsigned b(3); + Unsigned a(9u); + Unsigned b(3u); a *= b; - EXPECT_EQ(a, Unsigned(27)); - EXPECT_EQ(b, Unsigned(3)); + EXPECT_EQ(a, Unsigned(27u)); + EXPECT_EQ(b, Unsigned(3u)); } // Signed division assignment @@ -332,11 +332,11 @@ // Unsigned division assignment { - Unsigned a(12); - Unsigned b(3); + Unsigned a(12u); + Unsigned b(3u); a /= b; - EXPECT_EQ(a, Unsigned(4)); - EXPECT_EQ(b, Unsigned(3)); + EXPECT_EQ(a, Unsigned(4u)); + EXPECT_EQ(b, Unsigned(3u)); } // Signed modulo assignment @@ -350,11 +350,11 @@ // Unsigned modulo assignment { - Unsigned a(12); - Unsigned b(5); + Unsigned a(12u); + Unsigned b(5u); a %= b; - EXPECT_EQ(a, Unsigned(2)); - EXPECT_EQ(b, Unsigned(5)); + EXPECT_EQ(a, Unsigned(2u)); + EXPECT_EQ(b, Unsigned(5u)); } } @@ -365,6 +365,19 @@ EXPECT_EQ(std::numeric_limits<Signed>::min(), Signed(std::numeric_limits<int32_t>::min())); } +// Test that in Debug, there would be an error if somewhere in the code made the wrong assumption +// about what std::is_integral does for TypedIntegers. In release, tests the opposite, just so we +// remember to look at this if we change TypedIntegers to exist in Release too. +TEST_F(TypedIntegerTest, NotIntegralInDebug) { +#if defined(DAWN_ENABLE_ASSERTS) + static_assert(!std::is_integral_v<Unsigned>); + static_assert(!std::is_integral_v<Signed>); +#else + static_assert(std::is_integral_v<Unsigned>); + static_assert(std::is_integral_v<Signed>); +#endif +} + TEST_F(TypedIntegerTest, UnderlyingType) { static_assert(std::is_same_v<UnderlyingType<Unsigned>, uint32_t>); static_assert(std::is_same_v<UnderlyingType<Signed>, int32_t>); @@ -419,9 +432,9 @@ TEST_F(TypedIntegerDeathTest, UnsignedAdditionOverflow) { Unsigned value(std::numeric_limits<uint32_t>::max() - 1); - value + Unsigned(1); // Doesn't overflow. - EXPECT_DEATH(value + Unsigned(2), ""); // Overflows. - EXPECT_DEATH(value += Unsigned(2), ""); // Overflows. + value + Unsigned(1u); // Doesn't overflow. + EXPECT_DEATH(value + Unsigned(2u), ""); // Overflows. + EXPECT_DEATH(value += Unsigned(2u), ""); // Overflows. } TEST_F(TypedIntegerDeathTest, SignedAdditionOverflow) { @@ -441,11 +454,11 @@ } TEST_F(TypedIntegerDeathTest, UnsignedSubtractionUnderflow) { - Unsigned value(1); + Unsigned value(1u); - value - Unsigned(1); // Doesn't underflow. - EXPECT_DEATH(value - Unsigned(2), ""); // Underflows. - EXPECT_DEATH(value -= Unsigned(2), ""); // Underflows. + value - Unsigned(1u); // Doesn't underflow. + EXPECT_DEATH(value - Unsigned(2u), ""); // Underflows. + EXPECT_DEATH(value -= Unsigned(2u), ""); // Underflows. } TEST_F(TypedIntegerDeathTest, SignedSubtractionOverflow) { @@ -467,9 +480,9 @@ TEST_F(TypedIntegerDeathTest, UnsignedMultiplicationOverflow) { Unsigned value(std::numeric_limits<uint32_t>::max() / 2); - value* Unsigned(2); // Doesn't overflow. - EXPECT_DEATH(value * Unsigned(3), ""); // Overflows. - EXPECT_DEATH(value *= Unsigned(3), ""); // Overflows. + value* Unsigned(2u); // Doesn't overflow. + EXPECT_DEATH(value * Unsigned(3u), ""); // Overflows. + EXPECT_DEATH(value *= Unsigned(3u), ""); // Overflows. } TEST_F(TypedIntegerDeathTest, SignedMultiplicationOverflow) { @@ -489,11 +502,11 @@ } TEST_F(TypedIntegerDeathTest, UnsignedDivisionByZero) { - Unsigned value(1); + Unsigned value(1u); - value / Unsigned(1); // Doesn't underflow. - EXPECT_DEATH(value / Unsigned(0), ""); // DBZ. - EXPECT_DEATH(value /= Unsigned(0), ""); // DBZ. + value / Unsigned(1u); // Doesn't underflow. + EXPECT_DEATH(value / Unsigned(0u), ""); // DBZ. + EXPECT_DEATH(value /= Unsigned(0u), ""); // DBZ. } TEST_F(TypedIntegerDeathTest, SignedDivisionByZero) { @@ -516,11 +529,11 @@ } TEST_F(TypedIntegerDeathTest, UnsignedModuloByZero) { - Unsigned value(1); + Unsigned value(1u); - value % Unsigned(1); // Doesn't underflow. - EXPECT_DEATH(value % Unsigned(0), ""); // DBZ. - EXPECT_DEATH(value %= Unsigned(0), ""); // DBZ. + value % Unsigned(1u); // Doesn't underflow. + EXPECT_DEATH(value % Unsigned(0u), ""); // DBZ. + EXPECT_DEATH(value %= Unsigned(0u), ""); // DBZ. } TEST_F(TypedIntegerDeathTest, SignedModuloByZero) {