[dawn][tint] Fix modernize-avoid-c-style-cast, pt 1
- Trivial conversions from T(x) to T{x}
- One conversion to static_cast in eval_test.h due to CMake warning
config differences
- Aside: Remove unnecessary `u` suffixes in expressions like T{1u}
Bug: 548071770
Change-Id: I7a6d32a9a9f8bbc5dd8ccea5433c45e7bbd45f53
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/334538
Reviewed-by: Shrek Shao <shrekshao@google.com>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
diff --git a/src/dawn/common/Numeric.h b/src/dawn/common/Numeric.h
index 9f97edb..aa711df 100644
--- a/src/dawn/common/Numeric.h
+++ b/src/dawn/common/Numeric.h
@@ -40,13 +40,13 @@
template <typename T>
inline constexpr uint32_t u32_sizeof() {
static_assert(sizeof(T) <= std::numeric_limits<uint32_t>::max());
- return uint32_t(sizeof(T));
+ return uint32_t{sizeof(T)};
}
template <typename T>
inline constexpr uint32_t u32_alignof() {
static_assert(alignof(T) <= std::numeric_limits<uint32_t>::max());
- return uint32_t(alignof(T));
+ return uint32_t{alignof(T)};
}
} // namespace detail
diff --git a/src/dawn/common/RefCounted.cpp b/src/dawn/common/RefCounted.cpp
index f7d6026..0c265f9 100644
--- a/src/dawn/common/RefCounted.cpp
+++ b/src/dawn/common/RefCounted.cpp
@@ -39,8 +39,8 @@
namespace dawn {
static constexpr size_t kPayloadBits = 2;
-static constexpr uint64_t kPayloadMask = (uint64_t(1) << kPayloadBits) - 1;
-static constexpr uint64_t kRefCountIncrement = (uint64_t(1) << kPayloadBits);
+static constexpr uint64_t kPayloadMask = (uint64_t{1} << kPayloadBits) - 1;
+static constexpr uint64_t kRefCountIncrement = (uint64_t{1} << kPayloadBits);
RefCount::RefCount(uint64_t initCount, uint64_t payload)
: mRefCount(initCount * kRefCountIncrement + payload) {
diff --git a/src/dawn/common/Sha3.cpp b/src/dawn/common/Sha3.cpp
index 8c49580..77f0918 100644
--- a/src/dawn/common/Sha3.cpp
+++ b/src/dawn/common/Sha3.cpp
@@ -228,7 +228,7 @@
// Step 3
for (uint32_t j = 0; j < kLog2LaneBitWidth + 1; j++) {
if (kRoundConstantsBits[j + 7 * ir]) {
- RC |= uint64_t(1) << ((1 << j) - 1);
+ RC |= uint64_t{1} << ((1 << j) - 1);
}
}
diff --git a/src/dawn/native/BindGroupLayoutInternal.cpp b/src/dawn/native/BindGroupLayoutInternal.cpp
index f07eb4d..59f7749 100644
--- a/src/dawn/native/BindGroupLayoutInternal.cpp
+++ b/src/dawn/native/BindGroupLayoutInternal.cpp
@@ -371,7 +371,7 @@
"On entries[%u]: binding (%u) + arraySize (%u) is %u which is larger "
"than maxBindingsPerBindGroup (%u).",
i, arraySize, bindingNumber,
- uint32_t(arraySize) + uint32_t(bindingNumber),
+ uint32_t{arraySize} + uint32_t{bindingNumber},
kMaxBindingsPerBindGroupTyped);
}
@@ -655,7 +655,7 @@
continue;
}
- APIBindingIndex index = APIBindingIndex(uint32_t(i));
+ APIBindingIndex index = APIBindingIndex{uint32_t{i}};
const auto& [_, inserted] = result.apiBindingMap.emplace(binding.binding, index);
DAWN_CHECK(inserted);
}
@@ -795,7 +795,7 @@
const BindingInfo& BindGroupLayoutInternalBase::GetAPIBindingInfo(
APIBindingIndex bindingIndex) const {
DAWN_CHECK(!IsError());
- BindingIndex index = BindingIndex(uint32_t(bindingIndex));
+ BindingIndex index = BindingIndex{uint32_t{bindingIndex}};
DAWN_CHECK(index < mBindingInfo.size());
// Assert this is a user-facing binding and not an private internal binding.
DAWN_CHECK(mBindingMap.contains(mBindingInfo[index].binding));
@@ -824,7 +824,7 @@
DAWN_CHECK(!IsError());
// Assert this is a user-facing binding and not a private internal binding, and that it
// represents an internal bindings.
- BindingIndex index = BindingIndex(uint32_t(bindingIndex));
+ BindingIndex index = BindingIndex{uint32_t{bindingIndex}};
DAWN_CHECK(index < GetBindingCount());
DAWN_CHECK(mBindingMap.contains(mBindingInfo[index].binding));
return index;
@@ -931,14 +931,14 @@
uint32_t BindGroupLayoutInternalBase::GetStaticSamplerCount() const {
DAWN_CHECK(!IsError());
- return uint32_t(GetBindingTypeEnd(BindingTypeOrder_StaticSampler) -
- GetBindingTypeStart(BindingTypeOrder_StaticSampler));
+ return uint32_t{GetBindingTypeEnd(BindingTypeOrder_StaticSampler) -
+ GetBindingTypeStart(BindingTypeOrder_StaticSampler)};
}
uint32_t BindGroupLayoutInternalBase::GetExternalTextureCount() const {
DAWN_CHECK(!IsError());
- return uint32_t(GetBindingTypeEnd(BindingTypeOrder_ExternalTexture) -
- GetBindingTypeStart(BindingTypeOrder_ExternalTexture));
+ return uint32_t{GetBindingTypeEnd(BindingTypeOrder_ExternalTexture) -
+ GetBindingTypeStart(BindingTypeOrder_ExternalTexture)};
}
const BindingCounts& BindGroupLayoutInternalBase::GetValidationBindingCounts() const {
@@ -1020,8 +1020,8 @@
// Followed by:
// |---------buffer size array--------|
// |-uint64_t[mUnverifiedBufferCount]-|
- const size_t bufferCount = size_t(GetBindingTypeEnd(BindingTypeOrder_RegularBuffer));
- const size_t bindingCount = size_t(mBindingInfo.size());
+ const size_t bufferCount = size_t{GetBindingTypeEnd(BindingTypeOrder_RegularBuffer)};
+ const size_t bindingCount = size_t{mBindingInfo.size()};
size_t objectPointerStart = bufferCount * sizeof(BufferBindingData);
DAWN_CHECK(IsAligned(objectPointerStart, alignof(Ref<ObjectBase>)));
@@ -1033,8 +1033,8 @@
BindGroupLayoutInternalBase::BindingDataPointers
BindGroupLayoutInternalBase::ComputeBindingDataPointers(void* dataStart) const {
- const size_t bufferCount = size_t(GetBindingTypeEnd(BindingTypeOrder_RegularBuffer));
- const size_t bindingCount = size_t(mBindingInfo.size());
+ const size_t bufferCount = size_t{GetBindingTypeEnd(BindingTypeOrder_RegularBuffer)};
+ const size_t bindingCount = size_t{mBindingInfo.size()};
BufferBindingData* bufferData = reinterpret_cast<BufferBindingData*>(dataStart);
auto bindings = reinterpret_cast<Ref<ObjectBase>*>(DAWN_UNSAFE_TODO(bufferData + bufferCount));
diff --git a/src/dawn/native/Buffer.cpp b/src/dawn/native/Buffer.cpp
index a4ffb00..b11718d 100644
--- a/src/dawn/native/Buffer.cpp
+++ b/src/dawn/native/Buffer.cpp
@@ -1018,13 +1018,13 @@
DAWN_INVALID_IF(mIsHostMapped, "Host-mapped %s cannot be mapped again.", this);
- DAWN_INVALID_IF(uint64_t(offset) > mSize,
+ DAWN_INVALID_IF(uint64_t{offset} > mSize,
"Mapping offset (%u) is larger than the size (%u) of %s.", offset, mSize, this);
DAWN_INVALID_IF(offset % 8 != 0, "Offset (%u) must be a multiple of 8.", offset);
DAWN_INVALID_IF(size % 4 != 0, "Size (%u) must be a multiple of 4.", size);
- DAWN_INVALID_IF(uint64_t(size) > mSize - uint64_t(offset),
+ DAWN_INVALID_IF(uint64_t{size} > mSize - uint64_t{offset},
"Mapping range (offset:%u, size: %u) doesn't fit in the size (%u) of %s.",
offset, size, mSize, this);
diff --git a/src/dawn/native/ChainUtils.h b/src/dawn/native/ChainUtils.h
index 9b97dfc..eee98ab 100644
--- a/src/dawn/native/ChainUtils.h
+++ b/src/dawn/native/ChainUtils.h
@@ -160,7 +160,7 @@
// because std::bitset::operator| is not constexpr until C++23.
template <typename UnpackedPtrT, typename... Exts>
constexpr inline auto UnpackedPtrBitsetForExts = typename UnpackedPtrT::BitsetType(
- ((uint64_t(1) << UnpackedPtrIndexOf<UnpackedPtrT, Exts>) | ...));
+ ((uint64_t{1} << UnpackedPtrIndexOf<UnpackedPtrT, Exts>) | ...));
template <typename UnpackedPtrT>
constexpr inline auto UnpackedPtrBitsetForExts<UnpackedPtrT> = typename UnpackedPtrT::BitsetType(0);
diff --git a/src/dawn/native/CommandBufferStateTracker.cpp b/src/dawn/native/CommandBufferStateTracker.cpp
index e41c19e..7f7b941 100644
--- a/src/dawn/native/CommandBufferStateTracker.cpp
+++ b/src/dawn/native/CommandBufferStateTracker.cpp
@@ -645,7 +645,7 @@
VertexBufferSlot firstMissing = GetHighestBitIndexPlusOne(missingVertexBuffers).MinusOne();
return DAWN_VALIDATION_ERROR("Vertex buffer slot %u required by %s was not set.",
- uint8_t(firstMissing), GetRenderPipeline());
+ uint8_t{firstMissing}, GetRenderPipeline());
}
if (aspects[VALIDATION_ASPECT_IMMEDIATE_DATA]) {
diff --git a/src/dawn/native/CommandEncoder.cpp b/src/dawn/native/CommandEncoder.cpp
index cafe459..11e5f77 100644
--- a/src/dawn/native/CommandEncoder.cpp
+++ b/src/dawn/native/CommandEncoder.cpp
@@ -962,7 +962,7 @@
if (attachment.view) {
if (renderPassSampleCount) {
DAWN_INVALID_IF(
- i != ColorAttachmentIndex{uint8_t(0)},
+ i != ColorAttachmentIndex{uint8_t{0}},
"Only colorAttachment 0 may be used when the render pass has an explicit "
"sample count for MSAARenderToSingleSampled.");
DAWN_TRY(ValidateColorAttachmentRenderToSingleSampled(device, attachment,
diff --git a/src/dawn/native/CommandValidation.h b/src/dawn/native/CommandValidation.h
index 205e8d7..785f904 100644
--- a/src/dawn/native/CommandValidation.h
+++ b/src/dawn/native/CommandValidation.h
@@ -67,7 +67,7 @@
DAWN_FORCE_INLINE uint64_t Safe32x32(A a, B b) {
static_assert(std::is_same<A, uint32_t>::value, "'a' must be uint32_t");
static_assert(std::is_same<B, uint32_t>::value, "'b' must be uint32_t");
- return uint64_t(a) * uint64_t(b);
+ return uint64_t{a} * uint64_t{b};
}
// Overload to be used before/during validation. Handles bytesPerRow and rowPerImage being
diff --git a/src/dawn/native/ComputePassEncoder.cpp b/src/dawn/native/ComputePassEncoder.cpp
index 960bf9d..0240044 100644
--- a/src/dawn/native/ComputePassEncoder.cpp
+++ b/src/dawn/native/ComputePassEncoder.cpp
@@ -404,7 +404,7 @@
RestoreCommandBufferState(std::move(previousState));
// Return the new indirect buffer and indirect buffer offset.
- return std::make_pair(std::move(validatedIndirectBuffer), uint64_t(0));
+ return std::make_pair(std::move(validatedIndirectBuffer), uint64_t{0});
}
void ComputePassEncoder::APIDispatchWorkgroupsIndirect(BufferBase* indirectBuffer,
diff --git a/src/dawn/native/IndirectDrawValidationEncoder.cpp b/src/dawn/native/IndirectDrawValidationEncoder.cpp
index 44df5bc..b9e10ca 100644
--- a/src/dawn/native/IndirectDrawValidationEncoder.cpp
+++ b/src/dawn/native/IndirectDrawValidationEncoder.cpp
@@ -435,7 +435,7 @@
(limits.v1.maxStorageBufferBindingSize - sizeof(BatchInfo)) / kIndirectDrawByteSize;
return static_cast<uint32_t>(
std::min({batchDrawCallLimitByDispatchSize, batchDrawCallLimitByStorageBindingSize,
- uint64_t(std::numeric_limits<uint32_t>::max())}));
+ uint64_t{std::numeric_limits<uint32_t>::max()}}));
}
MaybeError EncodeIndirectDrawValidationCommands(DeviceBase* device,
diff --git a/src/dawn/native/IntegerTypes.h b/src/dawn/native/IntegerTypes.h
index cf0bc86..e8e0c58 100644
--- a/src/dawn/native/IntegerTypes.h
+++ b/src/dawn/native/IntegerTypes.h
@@ -129,7 +129,7 @@
// is incremented by one. This way to know if something is done executing, we just need to
// compare its serial with the currently completed serial.
using ExecutionSerial = TypedInteger<struct QueueSerialT, uint64_t>;
-constexpr ExecutionSerial kMaxExecutionSerial = ExecutionSerial(~uint64_t(0));
+constexpr ExecutionSerial kMaxExecutionSerial = ExecutionSerial(~uint64_t{0});
constexpr ExecutionSerial kBeginningOfGPUTime = ExecutionSerial(0u);
// An identifier that indicates which Pipeline a BindGroupLayout is compatible with. Pipelines
diff --git a/src/dawn/native/Limits.cpp b/src/dawn/native/Limits.cpp
index 7f713bb..3a243e5 100644
--- a/src/dawn/native/Limits.cpp
+++ b/src/dawn/native/Limits.cpp
@@ -354,14 +354,14 @@
limits->v1.maxVertexBufferArrayStride =
std::min(limits->v1.maxVertexBufferArrayStride, kMaxVertexBufferArrayStride);
limits->v1.maxColorAttachments =
- std::min(limits->v1.maxColorAttachments, uint32_t(kMaxColorAttachments));
+ std::min(limits->v1.maxColorAttachments, uint32_t{kMaxColorAttachments});
limits->v1.maxBindGroups = std::min(limits->v1.maxBindGroups, kMaxBindGroups);
limits->v1.maxBindGroupsPlusVertexBuffers =
std::min(limits->v1.maxBindGroupsPlusVertexBuffers, kMaxBindGroupsPlusVertexBuffers);
limits->v1.maxVertexAttributes =
- std::min(limits->v1.maxVertexAttributes, uint32_t(kMaxVertexAttributes));
+ std::min(limits->v1.maxVertexAttributes, uint32_t{kMaxVertexAttributes});
limits->v1.maxVertexBuffers =
- std::min(limits->v1.maxVertexBuffers, uint32_t(kMaxVertexBuffers));
+ std::min(limits->v1.maxVertexBuffers, uint32_t{kMaxVertexBuffers});
limits->v1.maxSampledTexturesPerShaderStage =
std::min(limits->v1.maxSampledTexturesPerShaderStage, kMaxSampledTexturesPerShaderStage);
limits->v1.maxSamplersPerShaderStage =
diff --git a/src/dawn/native/PipelineLayout.cpp b/src/dawn/native/PipelineLayout.cpp
index 3d7d9cf..7c844a8 100644
--- a/src/dawn/native/PipelineLayout.cpp
+++ b/src/dawn/native/PipelineLayout.cpp
@@ -353,7 +353,7 @@
const ShaderBindingInfo& shaderBinding,
const ExternalTextureBindingLayout* externalTextureBindingEntry) {
BindGroupLayoutEntry entry = {};
- entry.bindingArraySize = uint32_t(shaderBinding.arraySize);
+ entry.bindingArraySize = uint32_t{shaderBinding.arraySize};
MatchVariant(
shaderBinding.bindingInfo,
@@ -556,7 +556,7 @@
// Create the BindGroupLayoutEntry
BindGroupLayoutEntry entry = ConvertMetadataToEntry(
texelBufferLayouts, shaderBinding, &externalTextureBindingLayout);
- entry.binding = uint32_t(bindingNumber);
+ entry.binding = uint32_t{bindingNumber};
entry.visibility = StageBit(stage.shaderStage);
// Add it to our map of all entries, if there is an existing entry, then we
diff --git a/src/dawn/native/Queue.cpp b/src/dawn/native/Queue.cpp
index 2772566..aff0389 100644
--- a/src/dawn/native/Queue.cpp
+++ b/src/dawn/native/Queue.cpp
@@ -286,7 +286,7 @@
// To prevent the reentrant call from invalidating mTasksInFlight while in use by the first
// call, we remove the tasks to finish from the queue, update mTasksInFlight, then run the
// callbacks.
- TRACE_EVENT(DAWN_TRACE_CATEGORY(), "Queue::Tick", "finishedSerial", uint64_t(finishedSerial));
+ TRACE_EVENT(DAWN_TRACE_CATEGORY(), "Queue::Tick", "finishedSerial", uint64_t{finishedSerial});
std::vector<std::unique_ptr<TrackTaskCallback>> tasks;
mTasksInFlight.Use([&](auto tasksInFlight) {
@@ -396,7 +396,7 @@
DAWN_CHECK(IsPowerOfTwo(GetDevice()->GetOptimalBufferToTextureCopyOffsetAlignment()));
DAWN_CHECK(IsPowerOfTwo(blockInfo.byteSize));
uint64_t offsetAlignment = std::max(
- uint64_t(blockInfo.byteSize), GetDevice()->GetOptimalBufferToTextureCopyOffsetAlignment());
+ uint64_t{blockInfo.byteSize}, GetDevice()->GetOptimalBufferToTextureCopyOffsetAlignment());
// Buffer offset alignments must follow additional restrictions for depth stencil formats.
const Format& format = destination.texture->GetFormat();
diff --git a/src/dawn/native/RenderPipeline.cpp b/src/dawn/native/RenderPipeline.cpp
index 4efa368..6c1d4d4 100644
--- a/src/dawn/native/RenderPipeline.cpp
+++ b/src/dawn/native/RenderPipeline.cpp
@@ -262,7 +262,7 @@
return DAWN_VALIDATION_ERROR(
"Vertex attribute slot %u used in (%s, %s) is not present in the "
"VertexState.",
- uint8_t(firstMissing), descriptor->module, entryPoint);
+ uint8_t{firstMissing}, descriptor->module, entryPoint);
}
return entryPoint;
@@ -704,7 +704,7 @@
DAWN_INVALID_IF(!usesBlendSrc1,
"One of the blend factor uses `blend_src(1)` while `blend_src(1)` is "
"missing from the fragment shader outputs.");
- DAWN_INVALID_IF(descriptor->targets.size() != ColorAttachmentIndex{uint8_t{1u}},
+ DAWN_INVALID_IF(descriptor->targets.size() != ColorAttachmentIndex{uint8_t{1}},
"One of the blend factor uses `blend_src(1)` but the color targets count "
"is not 1.");
}
diff --git a/src/dawn/native/ResourceTable.cpp b/src/dawn/native/ResourceTable.cpp
index e3a9d84..aa18e67 100644
--- a/src/dawn/native/ResourceTable.cpp
+++ b/src/dawn/native/ResourceTable.cpp
@@ -59,9 +59,9 @@
MaybeError ValidateBindingResource(const DeviceBase* device, const BindingResource* resource) {
DAWN_INVALID_IF(resource->nextInChain != nullptr, "nextInChain is not null.");
- uint32_t resourceCount = uint32_t(resource->buffer != nullptr) +
- uint32_t(resource->textureView != nullptr) +
- uint32_t(resource->sampler != nullptr);
+ uint32_t resourceCount = uint32_t{resource->buffer != nullptr} +
+ uint32_t{resource->textureView != nullptr} +
+ uint32_t{resource->sampler != nullptr};
DAWN_INVALID_IF(resourceCount != 1,
"%i resources are specified (when there must be exactly 1).", resourceCount);
@@ -189,7 +189,7 @@
Span<uint32_t> data = mMetadataBuffer->GetMappedRangeSpan<uint32_t>();
// Store APISize at element 0 in the metadata buffer, which will be used in the shader to index
// default resources at APISize + resource type index.
- data[0] = uint32_t(mAPISize);
+ data[0] = uint32_t{mAPISize};
std::ranges::fill(data.subspan(1), 0u);
DAWN_TRY(mMetadataBuffer->Unmap());
@@ -271,7 +271,7 @@
}
UpdateWithDeviceValidation(slot, resource, "Insert");
- return uint32_t(slot);
+ return uint32_t{slot};
}
// No slot found, return the invalid binding.
@@ -294,7 +294,7 @@
}
uint32_t ResourceTableBase::APIGetSize() const {
- return uint32_t(mAPISize);
+ return uint32_t{mAPISize};
}
// static
diff --git a/src/dawn/native/ShaderModule.cpp b/src/dawn/native/ShaderModule.cpp
index b426061..a7207c7 100644
--- a/src/dawn/native/ShaderModule.cpp
+++ b/src/dawn/native/ShaderModule.cpp
@@ -617,7 +617,7 @@
"@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,
- uint32_t(layoutInfo.binding) - uint32_t(layoutInfo.indexInArray));
+ uint32_t{layoutInfo.binding} - uint32_t{layoutInfo.indexInArray});
// Validation specific to each type of binding.
return MatchVariant(
@@ -1252,7 +1252,7 @@
if (DelayedInvalidIf(
bindingNumber >= kMaxBindingsPerBindGroupTyped,
"Binding number (%u) exceeds the maxBindingsPerBindGroup limit (%u) - 1.",
- uint32_t(bindingNumber), kMaxBindingsPerBindGroup)) {
+ uint32_t{bindingNumber}, kMaxBindingsPerBindGroup)) {
continue;
}
diff --git a/src/dawn/native/Texture.cpp b/src/dawn/native/Texture.cpp
index d4d5675..f83155c 100644
--- a/src/dawn/native/Texture.cpp
+++ b/src/dawn/native/Texture.cpp
@@ -929,14 +929,14 @@
descriptor->arrayLayerCount, descriptor->mipLevelCount);
DAWN_INVALID_IF(
- uint64_t(descriptor->baseArrayLayer) + uint64_t(descriptor->arrayLayerCount) >
+ uint64_t{descriptor->baseArrayLayer} + uint64_t{descriptor->arrayLayerCount} >
uint64_t(texture->GetArrayLayers()),
"Texture view array layer range (baseArrayLayer: %u, arrayLayerCount: %u) exceeds the "
"texture's array layer count (%u).",
descriptor->baseArrayLayer, descriptor->arrayLayerCount, texture->GetArrayLayers());
DAWN_INVALID_IF(
- uint64_t(descriptor->baseMipLevel) + uint64_t(descriptor->mipLevelCount) >
+ uint64_t{descriptor->baseMipLevel} + uint64_t{descriptor->mipLevelCount} >
uint64_t(texture->GetNumMipLevels()),
"Texture view mip level range (baseMipLevel: %u, mipLevelCount: %u) exceeds the "
"texture's mip level count (%u).",
diff --git a/src/dawn/native/TintUtils.cpp b/src/dawn/native/TintUtils.cpp
index 8c77389..35ed300 100644
--- a/src/dawn/native/TintUtils.cpp
+++ b/src/dawn/native/TintUtils.cpp
@@ -146,9 +146,9 @@
const RenderPipelineBase& renderPipeline,
BindGroupIndex pullingBufferBindingSet) {
tint::VertexPullingConfig cfg;
- cfg.pulling_group = uint32_t(pullingBufferBindingSet);
+ cfg.pulling_group = uint32_t{pullingBufferBindingSet};
- cfg.vertex_state.resize(uint32_t(renderPipeline.GetVertexBufferCount()));
+ cfg.vertex_state.resize(uint32_t{renderPipeline.GetVertexBufferCount()});
for (VertexBufferSlot slot : renderPipeline.GetVertexBuffersUsed()) {
const VertexBufferInfo& dawnInfo = renderPipeline.GetVertexBuffer(slot);
tint::VertexBufferLayoutDescriptor* tintInfo =
diff --git a/src/dawn/native/TintUtils.h b/src/dawn/native/TintUtils.h
index cb78fd2..ac93826 100644
--- a/src/dawn/native/TintUtils.h
+++ b/src/dawn/native/TintUtils.h
@@ -111,8 +111,8 @@
}
tint::BindingPoint srcBindingPoint{
- .group = uint32_t(group),
- .binding = uint32_t(bindingNumber),
+ .group = uint32_t{group},
+ .binding = uint32_t{bindingNumber},
};
MatchVariant(
diff --git a/src/dawn/native/d3d11/BufferD3D11.cpp b/src/dawn/native/d3d11/BufferD3D11.cpp
index 9f46bc2..65cf1f4 100644
--- a/src/dawn/native/d3d11/BufferD3D11.cpp
+++ b/src/dawn/native/d3d11/BufferD3D11.cpp
@@ -357,11 +357,11 @@
// TODO(dawn:1705): handle mappedAtCreation for NonzeroClearResourcesOnCreationForTesting
// Allocate at least 4 bytes so clamped accesses are always in bounds.
- uint64_t size = std::max(GetSize(), uint64_t(4u));
+ uint64_t size = std::max(GetSize(), uint64_t{4});
// The validation layer requires:
// ByteWidth must be 12 or larger to be used with D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS.
if (GetInternalUsage() & wgpu::BufferUsage::Indirect) {
- size = std::max(size, uint64_t(12u));
+ size = std::max(size, uint64_t{12});
}
size_t alignment = D3D11BufferSizeAlignment(GetInternalUsage());
// Check for overflow, bufferDescriptor.ByteWidth is a UINT.
@@ -693,7 +693,7 @@
MaybeError Buffer::InitializeToZero(const ScopedCommandRecordingContext* commandContext) {
DAWN_ASSERT(NeedsInitialization());
- DAWN_TRY(ClearWholeBuffer(commandContext, uint8_t(0u)));
+ DAWN_TRY(ClearWholeBuffer(commandContext, uint8_t{0}));
SetInitialized(true);
GetDevice()->IncrementLazyClearCountForTesting();
diff --git a/src/dawn/native/d3d11/CommandBufferD3D11.cpp b/src/dawn/native/d3d11/CommandBufferD3D11.cpp
index a2441ff..9d248cc 100644
--- a/src/dawn/native/d3d11/CommandBufferD3D11.cpp
+++ b/src/dawn/native/d3d11/CommandBufferD3D11.cpp
@@ -122,7 +122,7 @@
for (VertexBufferSlot slot : vertexBuffersToApply) {
mCommandContext->GetD3D11DeviceContext3()->IASetVertexBuffers(
- uint8_t(slot), 1, &mD3D11Buffers[slot], &mStrides[slot], &mOffsets[slot]);
+ uint8_t{slot}, 1, &mD3D11Buffers[slot], &mStrides[slot], &mOffsets[slot]);
mDirtyVertexBuffers.reset(slot);
}
diff --git a/src/dawn/native/d3d11/QueueD3D11.cpp b/src/dawn/native/d3d11/QueueD3D11.cpp
index e9654c0..d450152 100644
--- a/src/dawn/native/d3d11/QueueD3D11.cpp
+++ b/src/dawn/native/d3d11/QueueD3D11.cpp
@@ -485,7 +485,7 @@
DAWN_TRY(commandContext.FlushBuffersForSyncingWithCPU());
- const uint64_t submitSerial = uint64_t(GetPendingCommandSerial());
+ const uint64_t submitSerial = uint64_t{GetPendingCommandSerial()};
{
TRACE_EVENT(DAWN_TRACE_CATEGORY(), "D3D11Device::SignalFence", "serial", submitSerial);
@@ -535,8 +535,8 @@
DAWN_ASSERT(mFence);
TRACE_EVENT(DAWN_TRACE_CATEGORY(), "D3D11Device::SignalFence", "serial",
- uint64_t(submitSerial));
- DAWN_TRY(CheckHRESULT(commandContext.Signal(mFence.Get(), uint64_t(submitSerial)),
+ uint64_t{submitSerial});
+ DAWN_TRY(CheckHRESULT(commandContext.Signal(mFence.Get(), uint64_t{submitSerial}),
"D3D11 command queue signal fence"));
}
@@ -627,7 +627,7 @@
if (serial > GetLastSubmittedCommandSerial()) {
return DAWN_FORMAT_INTERNAL_ERROR(
"Wait a serial (%llu) which is greater than last submitted command serial (%llu).",
- uint64_t(serial), uint64_t(GetLastSubmittedCommandSerial()));
+ uint64_t{serial}, uint64_t(GetLastSubmittedCommandSerial()));
}
return mPendingEvents.Use([=, &completedEventsList = mCompletedEvents](
@@ -698,8 +698,8 @@
DAWN_ASSERT(mFence);
TRACE_EVENT(DAWN_TRACE_CATEGORY(), "D3D11Device::SignalFence", "serial",
- uint64_t(submitSerial));
- DAWN_TRY(CheckHRESULT(commandContext.Signal(mFence.Get(), uint64_t(submitSerial)),
+ uint64_t{submitSerial});
+ DAWN_TRY(CheckHRESULT(commandContext.Signal(mFence.Get(), uint64_t{submitSerial}),
"D3D11 command queue signal fence"));
}
@@ -768,7 +768,7 @@
if (waitSerial > GetLastSubmittedCommandSerial()) {
return DAWN_FORMAT_INTERNAL_ERROR(
"Wait a serial (%llu) which is greater than last submitted command serial (%llu).",
- uint64_t(waitSerial), uint64_t(GetLastSubmittedCommandSerial()));
+ uint64_t{waitSerial}, uint64_t(GetLastSubmittedCommandSerial()));
}
// A coarse-grained D3D11 scope lock is unnecessary here. When D3D11 multithread protection is
diff --git a/src/dawn/native/d3d12/BindGroupLayoutD3D12.cpp b/src/dawn/native/d3d12/BindGroupLayoutD3D12.cpp
index 6bc2c3d..2d11197 100644
--- a/src/dawn/native/d3d12/BindGroupLayoutD3D12.cpp
+++ b/src/dawn/native/d3d12/BindGroupLayoutD3D12.cpp
@@ -124,7 +124,7 @@
D3D12_DESCRIPTOR_RANGE_TYPE descriptorRangeType =
WGPUBindingInfoToDescriptorRangeType(bindingInfo);
- mShaderRegisters[bindingIndex] = uint32_t(bindingIndex);
+ mShaderRegisters[bindingIndex] = uint32_t{bindingIndex};
// Static samplers aren't stored in the descriptor heap. Handle them separately.
if (std::holds_alternative<StaticSamplerBindingInfo>(bindingInfo.bindingLayout)) {
diff --git a/src/dawn/native/d3d12/BufferD3D12.cpp b/src/dawn/native/d3d12/BufferD3D12.cpp
index 3ee48e6..e57a668 100644
--- a/src/dawn/native/d3d12/BufferD3D12.cpp
+++ b/src/dawn/native/d3d12/BufferD3D12.cpp
@@ -179,7 +179,7 @@
MaybeError Buffer::Initialize(bool mappedAtCreation) {
// Allocate at least 4 bytes so clamped accesses are always in bounds.
- uint64_t size = std::max(GetSize(), uint64_t(4u));
+ uint64_t size = std::max(GetSize(), uint64_t{4});
size_t alignment = D3D12BufferSizeAlignment(GetInternalUsage());
if (size > std::numeric_limits<uint64_t>::max() - alignment) {
// Alignment would overflow.
@@ -244,7 +244,7 @@
auto scopedUseDuringCreation = UseInternal();
CommandRecordingContext* commandRecordingContext =
ToBackend(GetDevice()->GetQueue())->GetPendingCommandContext();
- DAWN_TRY(ClearBuffer(commandRecordingContext, uint8_t(1u)));
+ DAWN_TRY(ClearBuffer(commandRecordingContext, uint8_t{1}));
}
// Initialize the padding bytes to zero.
@@ -718,7 +718,7 @@
// TODO(crbug.com/dawn/484): skip initializing the buffer when it is created on a heap
// that has already been zero initialized.
- DAWN_TRY(ClearBuffer(commandContext, uint8_t(0u)));
+ DAWN_TRY(ClearBuffer(commandContext, uint8_t{0}));
SetInitialized(true);
GetDevice()->IncrementLazyClearCountForTesting();
diff --git a/src/dawn/native/d3d12/QueueD3D12.cpp b/src/dawn/native/d3d12/QueueD3D12.cpp
index 330ac44..828ff2d 100644
--- a/src/dawn/native/d3d12/QueueD3D12.cpp
+++ b/src/dawn/native/d3d12/QueueD3D12.cpp
@@ -71,7 +71,7 @@
// value.
mCommandQueue.As(&mD3d12SharingContract);
- DAWN_TRY(CheckHRESULT(d3d12Device->CreateFence(uint64_t(kBeginningOfGPUTime),
+ DAWN_TRY(CheckHRESULT(d3d12Device->CreateFence(uint64_t{kBeginningOfGPUTime},
D3D12_FENCE_FLAG_SHARED, IID_PPV_ARGS(&mFence)),
"D3D12 create fence"));
@@ -114,7 +114,7 @@
{
TRACE_EVENT(DAWN_TRACE_CATEGORY("recording"), "CommandBufferD3D12::RecordCommands",
- "serial", uint64_t(pendingSerial));
+ "serial", uint64_t{pendingSerial});
for (CommandBufferBase* commandBuffer : commands) {
DAWN_TRY(ToBackend(commandBuffer)->RecordCommands(commandContext));
}
diff --git a/src/dawn/native/d3d12/RenderPassBuilderD3D12.h b/src/dawn/native/d3d12/RenderPassBuilderD3D12.h
index 51b29c1..426185d 100644
--- a/src/dawn/native/d3d12/RenderPassBuilderD3D12.h
+++ b/src/dawn/native/d3d12/RenderPassBuilderD3D12.h
@@ -102,7 +102,7 @@
bool isStencilReadOnly);
private:
- ColorAttachmentIndex mHighestColorAttachmentIndexPlusOne{uint8_t(0)};
+ ColorAttachmentIndex mHighestColorAttachmentIndexPlusOne{uint8_t{0}};
bool mHasDepthOrStencil = false;
D3D12_RENDER_PASS_FLAGS mRenderPassFlags = D3D12_RENDER_PASS_FLAG_NONE;
D3D12_RENDER_PASS_DEPTH_STENCIL_DESC mRenderPassDepthStencilDesc;
diff --git a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp
index 3cf1116..3e1e86d 100644
--- a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp
+++ b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp
@@ -181,7 +181,7 @@
auto ToHLSLBindPoint = [&](BindGroupIndex group, BindingIndex index) -> tint::BindingPoint {
const BindGroupLayout* bgl = ToBackend(layout->GetBindGroupLayout(group));
return tint::BindingPoint{
- .group = uint32_t(group),
+ .group = uint32_t{group},
.binding = bgl->GetShaderRegister(index),
};
};
diff --git a/src/dawn/native/metal/BufferMTL.mm b/src/dawn/native/metal/BufferMTL.mm
index 166cb00..49fdb54 100644
--- a/src/dawn/native/metal/BufferMTL.mm
+++ b/src/dawn/native/metal/BufferMTL.mm
@@ -135,7 +135,7 @@
auto scopedUseDuringCreation = UseInternal();
CommandRecordingContext* commandContext =
ToBackend(GetDevice()->GetQueue())->GetPendingCommandContext();
- ClearBuffer(commandContext, uint8_t(1u));
+ ClearBuffer(commandContext, uint8_t{1});
}
// Initialize the padding bytes to zero.
@@ -287,7 +287,7 @@
void Buffer::InitializeToZero(CommandRecordingContext* commandContext) {
DAWN_ASSERT(NeedsInitialization());
- ClearBuffer(commandContext, uint8_t(0u));
+ ClearBuffer(commandContext, uint8_t{0});
SetInitialized(true);
GetDevice()->IncrementLazyClearCountForTesting();
diff --git a/src/dawn/native/metal/QueueMTL.mm b/src/dawn/native/metal/QueueMTL.mm
index 80ae7d2..9602d19 100644
--- a/src/dawn/native/metal/QueueMTL.mm
+++ b/src/dawn/native/metal/QueueMTL.mm
@@ -234,14 +234,14 @@
[*pendingCommands addCompletedHandler:^(id<MTLCommandBuffer>) {
TRACE_EVENT_NESTABLE_ASYNC_END0(DAWN_TRACE_CATEGORY("gpu_work"),
"DeviceMTL::SubmitPendingCommandBuffer",
- uint64_t(pendingSerial));
+ uint64_t{pendingSerial});
this->UpdateCompletedSerialTo(QueuePriority::Lowest, pendingSerial);
}];
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(DAWN_TRACE_CATEGORY("gpu_work"),
"DeviceMTL::SubmitPendingCommandBuffer",
- uint64_t(pendingSerial));
+ uint64_t{pendingSerial});
DAWN_ASSERT(mSharedFence);
[*pendingCommands encodeSignalEvent:mSharedFence->GetMTLSharedEvent()
diff --git a/src/dawn/native/metal/RenderPipelineMTL.mm b/src/dawn/native/metal/RenderPipelineMTL.mm
index fd37901..34cc73c 100644
--- a/src/dawn/native/metal/RenderPipelineMTL.mm
+++ b/src/dawn/native/metal/RenderPipelineMTL.mm
@@ -548,7 +548,7 @@
}
maxArrayStride =
std::max(maxArrayStride,
- GetVertexFormatInfo(attrib.format).byteSize + size_t(attrib.offset));
+ GetVertexFormatInfo(attrib.format).byteSize + size_t{attrib.offset});
}
layoutDesc.stepFunction = MTLVertexStepFunctionConstant;
layoutDesc.stepRate = 0;
diff --git a/src/dawn/native/metal/ShaderModuleMTL.mm b/src/dawn/native/metal/ShaderModuleMTL.mm
index 1177f25..ba12a99 100644
--- a/src/dawn/native/metal/ShaderModuleMTL.mm
+++ b/src/dawn/native/metal/ShaderModuleMTL.mm
@@ -142,7 +142,7 @@
case wgpu::BufferBindingType::ReadOnlyStorage:
case kInternalReadOnlyStorageBufferBinding:
arrayLength.bindpoint_to_size_index.emplace(
- tint::BindingPoint{uint32_t(group), uint32_t(bindingInfo.binding)},
+ tint::BindingPoint{uint32_t{group}, uint32_t{bindingInfo.binding}},
layout->GetBindingIndexInfo(stage)[group][index]);
break;
@@ -198,7 +198,7 @@
[&](const BufferBindingInfo& binding) {
if (binding.hasDynamicOffset) {
argBufferInfo.binding_info_to_offset_index.insert(
- {uint32_t(bindingIndex), curDynamicOffset++});
+ {uint32_t{bindingIndex}, curDynamicOffset++});
}
},
[&](const SamplerBindingInfo& bindingInfo) {},
@@ -233,7 +233,7 @@
GenerateBindingRemapping(layout, stage, [&](BindGroupIndex group, BindingIndex index) {
if (useArgumentBuffers) {
return tint::BindingPoint{
- .group = uint32_t(group),
+ .group = uint32_t{group},
.binding = ToMTLArgumentBufferIndex(index),
};
} else {
@@ -261,8 +261,8 @@
// Tell Tint to map (kPullingBufferBindingSet, slot) to this MSL buffer index.
tint::BindingPoint srcBindingPoint{
- .group = uint32_t(kPullingBufferBindingSet),
- .binding = uint8_t(slot),
+ .group = uint32_t{kPullingBufferBindingSet},
+ .binding = uint8_t{slot},
};
tint::BindingPoint dstBindingPoint{
.group = 0,
diff --git a/src/dawn/native/metal/UtilsMetal.h b/src/dawn/native/metal/UtilsMetal.h
index 5403600..3416afc 100644
--- a/src/dawn/native/metal/UtilsMetal.h
+++ b/src/dawn/native/metal/UtilsMetal.h
@@ -82,7 +82,7 @@
// When using argument buffers, we use the compacted BindingIndex directly in MSL, instead of
// remapping to per-resource-type indices (from GetBindingIndexInfo) like we do without argbufs.
inline uint32_t ToMTLArgumentBufferIndex(BindingIndex bindingIndex) {
- return uint32_t(bindingIndex);
+ return uint32_t{bindingIndex};
}
// For different reasons a WebGPU copy may need to be split into multiple copies for Metal. This
diff --git a/src/dawn/native/opengl/BufferGL.cpp b/src/dawn/native/opengl/BufferGL.cpp
index 83aecab..fd1bda2 100644
--- a/src/dawn/native/opengl/BufferGL.cpp
+++ b/src/dawn/native/opengl/BufferGL.cpp
@@ -109,7 +109,7 @@
if (GetUsage() & wgpu::BufferUsage::Uniform) {
alignment = 16u;
}
- mAllocatedSize = Align(std::max(GetSize(), uint64_t(4u)), alignment);
+ mAllocatedSize = Align(std::max(GetSize(), uint64_t{4}), alignment);
}
Buffer::~Buffer() = default;
diff --git a/src/dawn/native/opengl/CommandBufferGL.cpp b/src/dawn/native/opengl/CommandBufferGL.cpp
index 6e4577a..5d1f954 100644
--- a/src/dawn/native/opengl/CommandBufferGL.cpp
+++ b/src/dawn/native/opengl/CommandBufferGL.cpp
@@ -353,7 +353,7 @@
Sampler* sampler = ToBackend(s);
for (TextureUnit unit : mPipelineGL->GetTextureUnitsForSampler(samplerIndex)) {
- DAWN_GL_TRY(gl, BindSampler(uint32_t(unit), sampler->GetHandle()));
+ DAWN_GL_TRY(gl, BindSampler(uint32_t{unit}, sampler->GetHandle()));
}
return {};
@@ -380,7 +380,7 @@
if (layout.hasDynamicOffset) {
// Dynamic buffers are packed at the front of BindingIndices.
- offset += uint64_t(dynamicOffsets[bindingIndex]);
+ offset += uint64_t{dynamicOffsets[bindingIndex]};
}
GLenum target;
@@ -651,12 +651,12 @@
mInternalArrayLengthBufferData[ssboIndex] = static_cast<uint32_t>(size);
// Updating dirty range of the data vector
- mDirtyRangeArrayLength.begin = std::min(mDirtyRangeArrayLength.begin, size_t(ssboIndex));
- mDirtyRangeArrayLength.end = std::max(mDirtyRangeArrayLength.end, size_t(ssboIndex) + 1);
+ mDirtyRangeArrayLength.begin = std::min(mDirtyRangeArrayLength.begin, size_t{ssboIndex});
+ mDirtyRangeArrayLength.end = std::max(mDirtyRangeArrayLength.end, size_t{ssboIndex} + 1);
}
void ResetInternalUniformDataDirtyRangeArrayLength() {
- mDirtyRangeArrayLength = {size_t(mInternalArrayLengthBufferData.size()), 0};
+ mDirtyRangeArrayLength = {size_t{mInternalArrayLengthBufferData.size()}, 0};
}
void ResetInternalUniformDataBindgroupAndDirtyRange() {
diff --git a/src/dawn/native/opengl/ShaderModuleGL.cpp b/src/dawn/native/opengl/ShaderModuleGL.cpp
index ffa25c1..c147987 100644
--- a/src/dawn/native/opengl/ShaderModuleGL.cpp
+++ b/src/dawn/native/opengl/ShaderModuleGL.cpp
@@ -231,7 +231,7 @@
if (!metadata.textureQueries.empty()) {
textureBuiltinsFromUniform->ubo_binding = {
.group = 0,
- .binding = uint32_t(layout->GetInternalTextureBuiltinsUniformBinding()),
+ .binding = uint32_t{layout->GetInternalTextureBuiltinsUniformBinding()},
};
}
@@ -296,10 +296,10 @@
case kInternalReadOnlyStorageBufferBinding: {
// Use ssbo index as the indices for the buffer size lookups
// in the array length from uniform transform.
- tint::BindingPoint srcBindingPoint = {uint32_t(group),
- uint32_t(bindingInfo.binding)};
+ tint::BindingPoint srcBindingPoint = {uint32_t{group},
+ uint32_t{bindingInfo.binding}};
FlatBindingIndex ssboIndex = indexInfo[group][binding];
- options.bindpoint_to_size_index.emplace(srcBindingPoint, uint32_t(ssboIndex));
+ options.bindpoint_to_size_index.emplace(srcBindingPoint, uint32_t{ssboIndex});
break;
}
default:
@@ -382,7 +382,7 @@
GenerateBindingRemapping(layout, stage, [&](BindGroupIndex group, BindingIndex index) {
return tint::BindingPoint{
.group = 0,
- .binding = uint32_t(layout->GetBindingIndexInfo()[group][index]),
+ .binding = uint32_t{layout->GetBindingIndexInfo()[group][index]},
};
});
@@ -427,7 +427,7 @@
req.tintOptions.array_length_from_uniform.ubo_binding,
tint::BindingPoint{
.group = 0,
- .binding = uint32_t(layout->GetInternalArrayLengthUniformBinding()),
+ .binding = uint32_t{layout->GetInternalArrayLengthUniformBinding()},
});
}
}
diff --git a/src/dawn/native/opengl/UtilsEGL.cpp b/src/dawn/native/opengl/UtilsEGL.cpp
index e7284a4..47b8124 100644
--- a/src/dawn/native/opengl/UtilsEGL.cpp
+++ b/src/dawn/native/opengl/UtilsEGL.cpp
@@ -184,10 +184,10 @@
EGLenum result = EGL_FALSE;
if (egl.HasExt(EGLExt::FenceSync)) {
- result = egl.ClientWaitSyncKHR(mDisplay->GetDisplay(), mSync, flags, uint64_t(timeout));
+ result = egl.ClientWaitSyncKHR(mDisplay->GetDisplay(), mSync, flags, uint64_t{timeout});
} else {
DAWN_ASSERT(egl.IsAtLeastVersion(1, 5));
- result = egl.ClientWaitSync(mDisplay->GetDisplay(), mSync, flags, uint64_t(timeout));
+ result = egl.ClientWaitSync(mDisplay->GetDisplay(), mSync, flags, uint64_t{timeout});
}
DAWN_TRY(CheckEGL(egl, result != EGL_FALSE, "eglClientWaitSync"));
diff --git a/src/dawn/native/vulkan/BindGroupLayoutVk.cpp b/src/dawn/native/vulkan/BindGroupLayoutVk.cpp
index 41b7998..30fb0b7 100644
--- a/src/dawn/native/vulkan/BindGroupLayoutVk.cpp
+++ b/src/dawn/native/vulkan/BindGroupLayoutVk.cpp
@@ -102,9 +102,9 @@
}
VkDescriptorSetLayoutBinding vkBinding{
- .binding = uint32_t(bindingIndex),
+ .binding = uint32_t{bindingIndex},
.descriptorType = VulkanDescriptorType(bindingInfo),
- .descriptorCount = uint32_t(bindingInfo.arraySize),
+ .descriptorCount = uint32_t{bindingInfo.arraySize},
.stageFlags = VulkanShaderStages(bindingInfo.visibility),
.pImmutableSamplers = nullptr,
};
diff --git a/src/dawn/native/vulkan/BindGroupVk.cpp b/src/dawn/native/vulkan/BindGroupVk.cpp
index 06bb024..3575e7f 100644
--- a/src/dawn/native/vulkan/BindGroupVk.cpp
+++ b/src/dawn/native/vulkan/BindGroupVk.cpp
@@ -114,8 +114,8 @@
write.dstSet = dsSet;
// Arrays all have a single binding, so compute the binding index for the array, which is
// the same as the binding index for the 0th element.
- write.dstBinding = uint32_t(bindingIndex - bindingInfo.indexInArray);
- write.dstArrayElement = uint32_t(bindingInfo.indexInArray);
+ write.dstBinding = uint32_t{bindingIndex - bindingInfo.indexInArray};
+ write.dstArrayElement = uint32_t{bindingInfo.indexInArray};
write.descriptorCount = 1;
write.descriptorType = VulkanDescriptorType(bindingInfo);
diff --git a/src/dawn/native/vulkan/BufferVk.cpp b/src/dawn/native/vulkan/BufferVk.cpp
index 8089a19..33abde4 100644
--- a/src/dawn/native/vulkan/BufferVk.cpp
+++ b/src/dawn/native/vulkan/BufferVk.cpp
@@ -255,7 +255,7 @@
// Allocate at least 4 bytes so clamped accesses are always in bounds.
// Also, Vulkan requires the size to be non-zero.
- size = std::max(size, uint64_t(4u));
+ size = std::max(size, uint64_t{4});
if (size > std::numeric_limits<uint64_t>::max() - kAlignment) {
// Alignment would overlow.
@@ -275,7 +275,7 @@
// VkmemoryRequirements. See https://gitlab.khronos.org/vulkan/vulkan/issues/1904
// Any size with one of two top bits of VkDeviceSize set is a HUGE allocation and we can
// safely return an OOM error.
- if (mAllocatedSize.value() & (uint64_t(3) << uint64_t(62))) {
+ if (mAllocatedSize.value() & (uint64_t{3} << uint64_t{62})) {
return DAWN_OUT_OF_MEMORY_ERROR("Buffer size is HUGE and could cause overflows");
}
diff --git a/src/dawn/native/vulkan/DeviceVk.cpp b/src/dawn/native/vulkan/DeviceVk.cpp
index b19a9d2..ad5d09f 100644
--- a/src/dawn/native/vulkan/DeviceVk.cpp
+++ b/src/dawn/native/vulkan/DeviceVk.cpp
@@ -158,9 +158,9 @@
mExternalMemoryService = std::make_unique<external_memory::Service>(this);
- if (uint32_t(HasFeature(Feature::SharedFenceVkSemaphoreOpaqueFD)) +
- uint32_t(HasFeature(Feature::SharedFenceSyncFD)) +
- uint32_t(HasFeature(Feature::SharedFenceVkSemaphoreZirconHandle)) >
+ if (uint32_t{HasFeature(Feature::SharedFenceVkSemaphoreOpaqueFD)} +
+ uint32_t{HasFeature(Feature::SharedFenceSyncFD)} +
+ uint32_t{HasFeature(Feature::SharedFenceVkSemaphoreZirconHandle)} >
1) {
return DAWN_VALIDATION_ERROR("At most one of %s, %s, and %s may be enabled.",
wgpu::FeatureName::SharedFenceVkSemaphoreOpaqueFD,
diff --git a/src/dawn/native/vulkan/PhysicalDeviceVk.cpp b/src/dawn/native/vulkan/PhysicalDeviceVk.cpp
index 3f670e3..19d286c 100644
--- a/src/dawn/native/vulkan/PhysicalDeviceVk.cpp
+++ b/src/dawn/native/vulkan/PhysicalDeviceVk.cpp
@@ -833,7 +833,7 @@
// incorrect values on desktop drivers.
bool readjustFragmentCombinedOutputResources =
vkLimits.maxFragmentCombinedOutputResources > minFragmentCombinedOutputResources &&
- uint64_t(vkLimits.maxFragmentCombinedOutputResources) < maxFragmentCombinedOutputResources;
+ uint64_t{vkLimits.maxFragmentCombinedOutputResources} < maxFragmentCombinedOutputResources;
if (readjustFragmentCombinedOutputResources) {
// Split extra resources across the three other limits instead of using the default values
// since it would overflow.
@@ -904,11 +904,11 @@
vkLimits.maxComputeWorkGroupCount[2],
});
- if (!IsSubset(VkSampleCountFlags(VK_SAMPLE_COUNT_1_BIT | VK_SAMPLE_COUNT_4_BIT),
+ if (!IsSubset(VkSampleCountFlags{VK_SAMPLE_COUNT_1_BIT | VK_SAMPLE_COUNT_4_BIT},
vkLimits.framebufferColorSampleCounts)) {
return DAWN_INTERNAL_ERROR("Insufficient Vulkan limits for framebufferColorSampleCounts");
}
- if (!IsSubset(VkSampleCountFlags(VK_SAMPLE_COUNT_1_BIT | VK_SAMPLE_COUNT_4_BIT),
+ if (!IsSubset(VkSampleCountFlags{VK_SAMPLE_COUNT_1_BIT | VK_SAMPLE_COUNT_4_BIT},
vkLimits.framebufferDepthSampleCounts)) {
return DAWN_INTERNAL_ERROR("Insufficient Vulkan limits for framebufferDepthSampleCounts");
}
diff --git a/src/dawn/native/vulkan/PipelineLayoutVk.cpp b/src/dawn/native/vulkan/PipelineLayoutVk.cpp
index ad53df3..2543031 100644
--- a/src/dawn/native/vulkan/PipelineLayoutVk.cpp
+++ b/src/dawn/native/vulkan/PipelineLayoutVk.cpp
@@ -53,7 +53,7 @@
ResultOrError<Ref<RefCountedVkHandle<VkPipelineLayout>>> PipelineLayout::CreateVkPipelineLayout(
const Specialization& specialization) {
// Compute the array of VkDescriptorSetLayouts that will be chained in the create info.
- ityp::array<BindGroupIndex, VkDescriptorSetLayout, size_t(kMaxBindGroupsTyped) + 2> setLayouts;
+ ityp::array<BindGroupIndex, VkDescriptorSetLayout, size_t{kMaxBindGroupsTyped} + 2> setLayouts;
// The first VkDescriptorSetLayouts are the for framebuffer fetch and/or the resource table if
// needed.
diff --git a/src/dawn/native/vulkan/ResourceMemoryAllocatorVk.cpp b/src/dawn/native/vulkan/ResourceMemoryAllocatorVk.cpp
index b3b12b1..8a92e8b 100644
--- a/src/dawn/native/vulkan/ResourceMemoryAllocatorVk.cpp
+++ b/src/dawn/native/vulkan/ResourceMemoryAllocatorVk.cpp
@@ -75,9 +75,9 @@
mBuddySystem(
// Round down to a power of 2 that's <= mMemoryHeapSize. This will always
// be a multiple of heapBlockSize because heapBlockSize is a power of 2.
- uint64_t(1) << Log2(mMaxHeapSize),
+ uint64_t{1} << Log2(mMaxHeapSize),
// Take the min in the very unlikely case the memory heap is tiny.
- std::min(uint64_t(1) << Log2(mMaxHeapSize), heapBlockSize),
+ std::min(uint64_t{1} << Log2(mMaxHeapSize), heapBlockSize),
&mPooledMemoryAllocator) {
DAWN_ASSERT(IsPowerOfTwo(heapBlockSize));
}
diff --git a/src/dawn/native/vulkan/TextureVk.cpp b/src/dawn/native/vulkan/TextureVk.cpp
index d62ec03..122a2e7 100644
--- a/src/dawn/native/vulkan/TextureVk.cpp
+++ b/src/dawn/native/vulkan/TextureVk.cpp
@@ -1252,7 +1252,7 @@
// Inherit wgpu::TextureUsage::RenderAttachment, which may be an internal usage.
viewDesc.usage = wgpu::TextureUsage::None;
- ColorAttachmentIndex ca0(uint8_t(0));
+ ColorAttachmentIndex ca0(uint8_t{0});
DAWN_TRY_ASSIGN(beginCmd.colorAttachments[ca0].view,
device->CreateTextureView(this, &viewDesc));
diff --git a/src/dawn/native/webgpu/BindGroupLayoutWGPU.cpp b/src/dawn/native/webgpu/BindGroupLayoutWGPU.cpp
index 82f3671..ff51db4 100644
--- a/src/dawn/native/webgpu/BindGroupLayoutWGPU.cpp
+++ b/src/dawn/native/webgpu/BindGroupLayoutWGPU.cpp
@@ -142,9 +142,9 @@
const auto& bindingInfo = GetAPIBindingInfo(apiBindingIndex);
schema::BindGroupLayoutBinding binding{{
- .binding = uint32_t(bindingNumber),
+ .binding = uint32_t{bindingNumber},
.visibility = bindingInfo.visibility,
- .bindingArraySize = uint32_t(bindingInfo.arraySize),
+ .bindingArraySize = uint32_t{bindingInfo.arraySize},
}};
DAWN_TRY(MatchVariant(
diff --git a/src/dawn/native/webgpu/BindGroupWGPU.cpp b/src/dawn/native/webgpu/BindGroupWGPU.cpp
index 3a09f92..90be9d8 100644
--- a/src/dawn/native/webgpu/BindGroupWGPU.cpp
+++ b/src/dawn/native/webgpu/BindGroupWGPU.cpp
@@ -219,7 +219,7 @@
for (const auto& [bindingNumber, apiBindingIndex] : bindingMap) {
const auto& bindingInfo = layout->GetAPIBindingInfo(apiBindingIndex);
- uint32_t binding = uint32_t(bindingNumber);
+ uint32_t binding = uint32_t{bindingNumber};
MatchVariant(
bindingInfo.bindingLayout,
diff --git a/src/dawn/native/webgpu/CommandBufferHelpers.cpp b/src/dawn/native/webgpu/CommandBufferHelpers.cpp
index 5e7a404be..f8cee4e 100644
--- a/src/dawn/native/webgpu/CommandBufferHelpers.cpp
+++ b/src/dawn/native/webgpu/CommandBufferHelpers.cpp
@@ -52,7 +52,7 @@
schema::CommandBufferCommandSetBindGroupCmd data{{
.data = {{
- .index = uint32_t(cmd.index),
+ .index = uint32_t{cmd.index},
.bindGroupId = captureContext.GetId(cmd.group),
.dynamicOffsets =
std::vector<uint32_t>(dynamicOffsets.begin(), dynamicOffsets.end()),
@@ -134,7 +134,7 @@
const auto& cmd = *commands.NextCommand<SetVertexBufferCmd>();
schema::CommandBufferCommandSetVertexBufferCmd data{{
.data = {{
- .slot = uint32_t(cmd.slot),
+ .slot = uint32_t{cmd.slot},
.bufferId = captureContext.GetId(cmd.buffer),
.offset = cmd.offset,
.size = cmd.size,
diff --git a/src/dawn/native/webgpu/CommandBufferWGPU.cpp b/src/dawn/native/webgpu/CommandBufferWGPU.cpp
index 1cba7a9..5ea1b23 100644
--- a/src/dawn/native/webgpu/CommandBufferWGPU.cpp
+++ b/src/dawn/native/webgpu/CommandBufferWGPU.cpp
@@ -943,10 +943,10 @@
ColorAttachmentMask attachmentMask = cmd.attachmentState->GetColorAttachmentsMask();
ColorAttachmentIndex attachmentCount = GetHighestBitIndexPlusOne(attachmentMask);
- std::vector<schema::ColorAttachment> colorAttachments(size_t(attachmentCount),
+ std::vector<schema::ColorAttachment> colorAttachments(size_t{attachmentCount},
schema::ColorAttachment{});
for (ColorAttachmentIndex slot : attachmentMask) {
- colorAttachments[size_t(slot)] =
+ colorAttachments[size_t{slot}] =
ToSchema(captureContext, cmd.colorAttachments[slot]);
}
diff --git a/src/dawn/native/webgpu/RenderPipelineWGPU.cpp b/src/dawn/native/webgpu/RenderPipelineWGPU.cpp
index bad301a..99a7589 100644
--- a/src/dawn/native/webgpu/RenderPipelineWGPU.cpp
+++ b/src/dawn/native/webgpu/RenderPipelineWGPU.cpp
@@ -237,7 +237,7 @@
attributes.push_back({{
.format = attrib.format,
.offset = attrib.offset,
- .shaderLocation = uint32_t(attrib.shaderLocation),
+ .shaderLocation = uint32_t{attrib.shaderLocation},
}});
}
@@ -277,7 +277,7 @@
// on replay.
ColorAttachmentMask attachmentMask = GetColorAttachmentsMask();
ColorAttachmentIndex attachmentCount = GetHighestBitIndexPlusOne(attachmentMask);
- std::vector<schema::ColorTargetState> targets(size_t(attachmentCount),
+ std::vector<schema::ColorTargetState> targets(size_t{attachmentCount},
kDefaultColorTargetState);
if (fragment.module != nullptr) {
@@ -293,7 +293,7 @@
: schema::ExpandResolveMode::Disabled;
}
- targets[size_t(slot)] = {{
+ targets[size_t{slot}] = {{
.format = target.format,
.blend{{
.color = ToSchema(target.blend ? &target.blend->color : nullptr),
diff --git a/src/dawn/node/binding/Converter.cpp b/src/dawn/node/binding/Converter.cpp
index 169277d..37e80bd 100644
--- a/src/dawn/node/binding/Converter.cpp
+++ b/src/dawn/node/binding/Converter.cpp
@@ -2113,7 +2113,7 @@
}
// The offset is in elements.
- if (data_offset_elements > uint64_t(src.size / src.bytesPerElement)) {
+ if (data_offset_elements > uint64_t{src.size / src.bytesPerElement}) {
binding::Errors::OperationError(env, "dataOffset is larger than data's size.")
.ThrowAsJavaScriptException();
return false;
@@ -2124,7 +2124,7 @@
// Size defaults to dataSize - dataOffset. Instead of computing in elements, we directly
// use it in bytes, and convert the provided value, if any, in bytes.
- uint64_t size64 = uint64_t(src.size);
+ uint64_t size64 = uint64_t{src.size};
if (size_elements.has_value()) {
if (size_elements.value() > std::numeric_limits<uint64_t>::max() / src.bytesPerElement) {
binding::Errors::OperationError(env, "size overflows.").ThrowAsJavaScriptException();
@@ -2133,7 +2133,7 @@
size64 = size_elements.value() * src.bytesPerElement;
}
- if (size64 > uint64_t(src.size)) {
+ if (size64 > uint64_t{src.size}) {
binding::Errors::OperationError(env, "size + dataOffset is larger than data's size.")
.ThrowAsJavaScriptException();
return false;
diff --git a/src/dawn/node/binding/GPUBuffer.cpp b/src/dawn/node/binding/GPUBuffer.cpp
index caa4ad7..bf34b3b 100644
--- a/src/dawn/node/binding/GPUBuffer.cpp
+++ b/src/dawn/node/binding/GPUBuffer.cpp
@@ -75,7 +75,7 @@
pending_map_.emplace(ctx->promise);
buffer_.MapAsync(
- mode, dawn::checked_cast<size_t>(uint64_t(offset)), dawn::checked_cast<size_t>(rangeSize),
+ mode, dawn::checked_cast<size_t>(uint64_t{offset}), dawn::checked_cast<size_t>(rangeSize),
wgpu::CallbackMode::AllowProcessEvents,
[ctx = std::move(ctx), this](wgpu::MapAsyncStatus status, wgpu::StringView) {
// The promise may already have been resolved with an AbortError if there was an early
@@ -125,10 +125,10 @@
auto* ptr =
(desc_.usage & wgpu::BufferUsage::MapWrite)
- ? buffer_.GetMappedRange(dawn::checked_cast<size_t>(uint64_t(offset)),
+ ? buffer_.GetMappedRange(dawn::checked_cast<size_t>(uint64_t{offset}),
dawn::checked_cast<size_t>(s))
: const_cast<void*>(buffer_.GetConstMappedRange(
- dawn::checked_cast<size_t>(uint64_t(offset)), dawn::checked_cast<size_t>(s)));
+ dawn::checked_cast<size_t>(uint64_t{offset}), dawn::checked_cast<size_t>(s)));
if (!ptr) {
Errors::OperationError(env).ThrowAsJavaScriptException();
return {};
diff --git a/src/dawn/node/interop/Core.h b/src/dawn/node/interop/Core.h
index cbdc398..8cb35b2 100644
--- a/src/dawn/node/interop/Core.h
+++ b/src/dawn/node/interop/Core.h
@@ -561,7 +561,7 @@
// Note that the number must both be representable in the integer type, but also below
// MAX_SAFE_INTEGER after which consecutive double values might skip over some integer
// values.
- constexpr double kMaxSafeInteger = (uint64_t(1) << 53) - uint64_t(1);
+ constexpr double kMaxSafeInteger = (uint64_t{1} << 53) - uint64_t{1};
constexpr double kMinSafeInteger = -kMaxSafeInteger;
constexpr double kMin =
diff --git a/src/dawn/tests/DawnTest.cpp b/src/dawn/tests/DawnTest.cpp
index 0971b75..22dafb5 100644
--- a/src/dawn/tests/DawnTest.cpp
+++ b/src/dawn/tests/DawnTest.cpp
@@ -1798,7 +1798,7 @@
uint64_t offset,
uint64_t size,
detail::Expectation* expectation) {
- uint64_t alignedSize = Align(size, uint64_t(4));
+ uint64_t alignedSize = Align(size, uint64_t{4});
auto readback = ReserveReadback(device, alignedSize);
// We need to enqueue the copy immediately because by the time we resolve the expectation,
diff --git a/src/dawn/tests/end2end/CaptureAndReplayTests.cpp b/src/dawn/tests/end2end/CaptureAndReplayTests.cpp
index 3e35720..995b2e8 100644
--- a/src/dawn/tests/end2end/CaptureAndReplayTests.cpp
+++ b/src/dawn/tests/end2end/CaptureAndReplayTests.cpp
@@ -1584,7 +1584,7 @@
// We just expect no errors.
}
-constexpr static uint64_t kSentinelValue = ~uint64_t(0u);
+constexpr static uint64_t kSentinelValue = ~uint64_t{0};
class OcclusionExpectation : public detail::Expectation {
public:
enum class Result { Zero, NonZero };
diff --git a/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp b/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp
index ba3ec78..4e5e241 100644
--- a/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp
+++ b/src/dawn/tests/end2end/ComputeLayoutMemoryBufferTests.cpp
@@ -430,7 +430,7 @@
o << "\n";
uint32_t i = 0;
for (auto byte : byteBuffer) {
- o << std::hex << std::setw(2) << std::setfill('0') << uint32_t(byte);
+ o << std::hex << std::setw(2) << std::setfill('0') << uint32_t{byte};
if (i < 31) {
o << " ";
i++;
@@ -612,7 +612,7 @@
// Structure size: RoundUp(AlignOf(S), OffsetOf(S, L) + SizeOf(S, L))
// https://www.w3.org/TR/WGSL/#storage-class-constraints
// RequiredAlignOf(S, uniform): RoundUp(16, max(AlignOf(T0), ..., AlignOf(TN)))
- uint32_t dataAlign = isUniform ? std::max(size_t(16u), field.GetAlign()) : field.GetAlign();
+ uint32_t dataAlign = isUniform ? std::max(size_t{16}, field.GetAlign()) : field.GetAlign();
// https://www.w3.org/TR/WGSL/#structure-layout-rules
// Note: When underlying the target is a Vulkan device, we assume the device does not support
diff --git a/src/dawn/tests/end2end/DepthStencilCopyTests.cpp b/src/dawn/tests/end2end/DepthStencilCopyTests.cpp
index e5c7fe0..93201c3 100644
--- a/src/dawn/tests/end2end/DepthStencilCopyTests.cpp
+++ b/src/dawn/tests/end2end/DepthStencilCopyTests.cpp
@@ -320,7 +320,7 @@
uint32_t result =
bytesPerImage * (depth - 1) + (bytesPerRow * (height - 1) + width * bytesPerPixel);
- return alignForMultipleOf4Bytes ? Align(result, uint64_t(4)) : result;
+ return alignForMultipleOf4Bytes ? Align(result, uint64_t{4}) : result;
}
wgpu::ShaderModule mVertexModule;
diff --git a/src/dawn/tests/end2end/DepthStencilLoadOpTests.cpp b/src/dawn/tests/end2end/DepthStencilLoadOpTests.cpp
index 767dfa3..cb8b000 100644
--- a/src/dawn/tests/end2end/DepthStencilLoadOpTests.cpp
+++ b/src/dawn/tests/end2end/DepthStencilLoadOpTests.cpp
@@ -149,7 +149,7 @@
kU16DepthValues[mipLevel]);
EXPECT_TEXTURE_EQ(expectedDepth.data(), texture, {0, 0}, {mipSize, mipSize},
mipLevel, wgpu::TextureAspect::DepthOnly,
- /* bytesPerRow */ 0, /* tolerance */ uint16_t(1))
+ /* bytesPerRow */ 0, /* tolerance */ uint16_t{1})
<< "copy depth mip " << mipLevel;
} else {
std::vector<float> expectedDepth(static_cast<size_t>(mipSize) * mipSize,
@@ -333,7 +333,7 @@
CheckMipLevel(0u);
}
-// Test when stencilClearValue overflows uint16_t(>65535), only the last 8 bits will be applied as
+// Test when stencilClearValue overflows uint16_t (>65535), only the last 8 bits will be applied as
// the stencil clear value in encoder.BeginRenderPass() (currently Dawn only supports 8-bit stencil
// format).
TEST_P(StencilClearValueOverflowTest, StencilClearValueOverFlowUint16) {
diff --git a/src/dawn/tests/end2end/DepthStencilSamplingTests.cpp b/src/dawn/tests/end2end/DepthStencilSamplingTests.cpp
index 5a473c5..956469f 100644
--- a/src/dawn/tests/end2end/DepthStencilSamplingTests.cpp
+++ b/src/dawn/tests/end2end/DepthStencilSamplingTests.cpp
@@ -793,10 +793,10 @@
wgpu::TextureFormat format = GetParam().mTextureFormat;
DoSamplingExtraStencilComponentsRenderTest(TestAspectAndSamplerType::StencilAsUint, format,
- {uint8_t(42), uint8_t(37)});
+ {uint8_t{42}, uint8_t{37}});
DoSamplingExtraStencilComponentsComputeTest(TestAspectAndSamplerType::StencilAsUint, format,
- {uint8_t(42), uint8_t(37)});
+ {uint8_t{42}, uint8_t{37}});
}
// Test sampling both depth and stencil with a render/compute pipeline works.
diff --git a/src/dawn/tests/end2end/DeviceLostTests.cpp b/src/dawn/tests/end2end/DeviceLostTests.cpp
index 1eb7cd2..9bfc097 100644
--- a/src/dawn/tests/end2end/DeviceLostTests.cpp
+++ b/src/dawn/tests/end2end/DeviceLostTests.cpp
@@ -298,7 +298,7 @@
// allocates `0x8000000000000000`
DAWN_TEST_UNSUPPORTED_IF(IsTsan());
- uint64_t kStupidLarge = uint64_t(1) << uint64_t(63);
+ uint64_t kStupidLarge = uint64_t{1} << uint64_t{63};
LoseDeviceForTesting();
// Each test either expects null or an ErrorBuffer.
diff --git a/src/dawn/tests/end2end/EventTests.cpp b/src/dawn/tests/end2end/EventTests.cpp
index 4aff84c..ba2f103 100644
--- a/src/dawn/tests/end2end/EventTests.cpp
+++ b/src/dawn/tests/end2end/EventTests.cpp
@@ -493,12 +493,12 @@
std::tie(instance2, device2) = CreateExtraInstance(GetWireHelper(), &desc);
// UnsupportedTimeout is still validated if no futures are passed.
- for (uint64_t timeout : {uint64_t(1), uint64_t(0), UINT64_MAX}) {
+ for (uint64_t timeout : {uint64_t{1}, uint64_t{0}, UINT64_MAX}) {
ASSERT_EQ(instance2.WaitAny(0, nullptr, timeout),
timeout > 0 ? wgpu::WaitStatus::Error : wgpu::WaitStatus::Success);
}
- for (uint64_t timeout : {uint64_t(1), uint64_t(0), UINT64_MAX}) {
+ for (uint64_t timeout : {uint64_t{1}, uint64_t{0}, UINT64_MAX}) {
wgpu::WaitStatus status =
instance2.WaitAny(device2.GetQueue().OnSubmittedWorkDone(
wgpu::CallbackMode::WaitAnyOnly,
@@ -517,7 +517,7 @@
// TODO(crbug.com/474391710): Flaky on Snapdragon X Elite w/ D3D11.
DAWN_SUPPRESS_TEST_IF(IsWindows() && IsQualcomm() && IsD3D11());
- for (uint64_t timeout : {uint64_t(0), uint64_t(1)}) {
+ for (uint64_t timeout : {uint64_t{0}, uint64_t{1}}) {
// We don't support values higher than the default (64), and if you ask for lower than 64
// you still get 64. DawnTest doesn't request anything (so requests 0) so gets 64.
for (size_t count : {kTimedWaitAnyMaxCountDefault, kTimedWaitAnyMaxCountDefault + 1}) {
@@ -547,7 +547,7 @@
wgpu::Queue queue1 = queue;
wgpu::Queue queue2 = device2.GetQueue();
- for (uint64_t timeout : {uint64_t(0), uint64_t(1)}) {
+ for (uint64_t timeout : {uint64_t{0}, uint64_t{1}}) {
std::vector<wgpu::FutureWaitInfo> infos{{
{queue1.OnSubmittedWorkDone(wgpu::CallbackMode::WaitAnyOnly,
[](wgpu::QueueWorkDoneStatus, wgpu::StringView) {})},
diff --git a/src/dawn/tests/end2end/FramebufferFetchTests.cpp b/src/dawn/tests/end2end/FramebufferFetchTests.cpp
index 3de8c46..a35d99c 100644
--- a/src/dawn/tests/end2end/FramebufferFetchTests.cpp
+++ b/src/dawn/tests/end2end/FramebufferFetchTests.cpp
@@ -102,7 +102,7 @@
// The 10 points should have successfully used framebuffer fetch to do increment ten times
// without races.
- EXPECT_TEXTURE_EQ(uint32_t(10), texture, {0, 0});
+ EXPECT_TEXTURE_EQ(uint32_t{10}, texture, {0, 0});
}
// Check that FramebufferFetch works correctly when switching between pipelines that use and do not
@@ -254,10 +254,10 @@
// The 10 points should have successfully used framebuffer fetch to do increment ten times
// without races.
- EXPECT_TEXTURE_EQ(uint32_t(0), texture0, {0, 0});
- EXPECT_TEXTURE_EQ(uint32_t(10), texture1, {0, 0});
- EXPECT_TEXTURE_EQ(uint32_t(20), texture2, {0, 0});
- EXPECT_TEXTURE_EQ(uint32_t(30), texture3, {0, 0});
+ EXPECT_TEXTURE_EQ(uint32_t{0}, texture0, {0, 0});
+ EXPECT_TEXTURE_EQ(uint32_t{10}, texture1, {0, 0});
+ EXPECT_TEXTURE_EQ(uint32_t{20}, texture2, {0, 0});
+ EXPECT_TEXTURE_EQ(uint32_t{30}, texture3, {0, 0});
}
// Check with multiple render attachments
@@ -317,8 +317,8 @@
// The 10 points should have successfully used framebuffer fetch to do in/decrement ten times
// without races.
- EXPECT_TEXTURE_EQ(uint32_t(10), texture0, {0, 0});
- EXPECT_TEXTURE_EQ(int32_t(-10), texture1, {0, 0});
+ EXPECT_TEXTURE_EQ(uint32_t{10}, texture0, {0, 0});
+ EXPECT_TEXTURE_EQ(int32_t{-10}, texture1, {0, 0});
EXPECT_TEXTURE_EQ(static_cast<float>(10), texture2, {0, 0});
EXPECT_TEXTURE_EQ(utils::RGBA8(10, 10, 10, 10), texture3, {0, 0});
}
@@ -371,8 +371,8 @@
// The first attachment is discard, but it's value of (ten increments + loaded value) is in the
// second attachment.
- EXPECT_TEXTURE_EQ(uint32_t(0), texture0, {0, 0});
- EXPECT_TEXTURE_EQ(uint32_t(10 + 1789), texture1, {0, 0});
+ EXPECT_TEXTURE_EQ(uint32_t{0}, texture0, {0, 0});
+ EXPECT_TEXTURE_EQ(uint32_t{10 + 1789}, texture1, {0, 0});
}
// Checks that with the framebuffer fetch feature enabled and a multisampled color attachment, a
@@ -555,7 +555,7 @@
wgpu::CommandBuffer commands = encoder.Finish();
queue.Submit(1, &commands);
- EXPECT_TEXTURE_EQ(uint32_t(i + 1), texture, {0, 0});
+ EXPECT_TEXTURE_EQ(uint32_t{i + 1}, texture, {0, 0});
}
}
diff --git a/src/dawn/tests/end2end/MaxLimitTests.cpp b/src/dawn/tests/end2end/MaxLimitTests.cpp
index 875b6d3..3480142 100644
--- a/src/dawn/tests/end2end/MaxLimitTests.cpp
+++ b/src/dawn/tests/end2end/MaxLimitTests.cpp
@@ -150,7 +150,7 @@
// TODO(crbug.com/dawn/1160): Usually can't actually allocate a buffer this large
// because allocating the buffer for zero-initialization fails.
maxBufferBindingSize =
- std::min(maxBufferBindingSize, uint64_t(2) * 1024 * 1024 * 1024);
+ std::min(maxBufferBindingSize, uint64_t{2} * 1024 * 1024 * 1024);
// With WARP or on 32-bit platforms, such large buffer allocations often fail.
#if DAWN_PLATFORM_IS(32_BIT)
if (IsWindows()) {
@@ -159,7 +159,7 @@
#endif
if (IsWARP()) {
maxBufferBindingSize =
- std::min(maxBufferBindingSize, uint64_t(512) * 1024 * 1024);
+ std::min(maxBufferBindingSize, uint64_t{512} * 1024 * 1024);
}
maxBufferBindingSize = Align(maxBufferBindingSize - 3u, 4);
shader = R"(
@@ -187,7 +187,7 @@
// Clamp to not exceed the maximum i32 value for the WGSL @size(x) annotation.
maxBufferBindingSize = std::min(maxBufferBindingSize,
- uint64_t(std::numeric_limits<int32_t>::max()) + 8);
+ uint64_t{std::numeric_limits<int32_t>::max()} + 8);
maxBufferBindingSize = Align(maxBufferBindingSize - 3u, 4);
const uint64_t kMaxStructMemberU32ArraySize = 65535ULL * 4;
diff --git a/src/dawn/tests/end2end/NonzeroBufferCreationTests.cpp b/src/dawn/tests/end2end/NonzeroBufferCreationTests.cpp
index 251c965..0cd7a7a 100644
--- a/src/dawn/tests/end2end/NonzeroBufferCreationTests.cpp
+++ b/src/dawn/tests/end2end/NonzeroBufferCreationTests.cpp
@@ -47,7 +47,7 @@
wgpu::Buffer buffer = device.CreateBuffer(&descriptor);
- std::vector<uint8_t> expectedData(kSize, uint8_t(1u));
+ std::vector<uint8_t> expectedData(kSize, uint8_t{1});
DAWN_UNSAFE_TODO(EXPECT_BUFFER_U32_RANGE_EQ(reinterpret_cast<uint32_t*>(expectedData.data()),
buffer, 0, kSize / sizeof(uint32_t)));
}
@@ -63,7 +63,7 @@
wgpu::Buffer buffer = device.CreateBuffer(&descriptor);
- std::vector<uint8_t> expectedData(kSize, uint8_t(1u));
+ std::vector<uint8_t> expectedData(kSize, uint8_t{1});
DAWN_UNSAFE_TODO(EXPECT_BUFFER_U32_RANGE_EQ(reinterpret_cast<uint32_t*>(expectedData.data()),
buffer, 0, kSize / sizeof(uint32_t)));
}
@@ -86,7 +86,7 @@
defaultDescriptor.size = kSize;
defaultDescriptor.mappedAtCreation = true;
- const std::vector<uint8_t> expectedData(kSize, uint8_t(1u));
+ const std::vector<uint8_t> expectedData(kSize, uint8_t{1});
const uint32_t* expectedDataPtr =
DAWN_UNSAFE_TODO(reinterpret_cast<const uint32_t*>(expectedData.data()));
diff --git a/src/dawn/tests/end2end/QueryTests.cpp b/src/dawn/tests/end2end/QueryTests.cpp
index 44575d8..1c28de4 100644
--- a/src/dawn/tests/end2end/QueryTests.cpp
+++ b/src/dawn/tests/end2end/QueryTests.cpp
@@ -36,7 +36,7 @@
namespace {
// Clear the content of the result buffer into 0xFFFFFFFF.
-constexpr static uint64_t kSentinelValue = ~uint64_t(0u);
+constexpr static uint64_t kSentinelValue = ~uint64_t{0};
constexpr static uint64_t kZero = 0u;
constexpr static unsigned int kRTSize = 4;
constexpr uint64_t kMinDestinationOffset = kQueryResolveAlignment;
diff --git a/src/dawn/tests/end2end/ResourceTableTests.cpp b/src/dawn/tests/end2end/ResourceTableTests.cpp
index 77ffb14..8aece02 100644
--- a/src/dawn/tests/end2end/ResourceTableTests.cpp
+++ b/src/dawn/tests/end2end/ResourceTableTests.cpp
@@ -3138,8 +3138,8 @@
queue.Submit(1, &commands);
// Check results
- EXPECT_PIXEL_U32_EQ(uint32_t{0xBEEFu}, beefTexture, 0, 0);
- EXPECT_PIXEL_U32_EQ(uint32_t{0xCAFEu}, cafeTexture, 0, 0);
+ EXPECT_PIXEL_U32_EQ(uint32_t{0xBEEF}, beefTexture, 0, 0);
+ EXPECT_PIXEL_U32_EQ(uint32_t{0xCAFE}, cafeTexture, 0, 0);
}
wgpu::TextureUsage TextureUsageForWriteKind(BindfulWriteKind kind) {
diff --git a/src/dawn/tests/perf_tests/LoadStoreOpPerfTest.cpp b/src/dawn/tests/perf_tests/LoadStoreOpPerfTest.cpp
index 4d4ec9b..e2c8602 100644
--- a/src/dawn/tests/perf_tests/LoadStoreOpPerfTest.cpp
+++ b/src/dawn/tests/perf_tests/LoadStoreOpPerfTest.cpp
@@ -174,7 +174,7 @@
// Clear the textures
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
- float colorScale = std::max(0.1f, i / float(kNumTextures));
+ float colorScale = std::max(0.1f, static_cast<float>(i) / kNumTextures);
{
utils::ComboRenderPassDescriptor renderPass({msaaTextureView[i]});
renderPass.cColorAttachments[0].loadOp = wgpu::LoadOp::Clear;
diff --git a/src/dawn/tests/unittests/CommandAllocatorTests.cpp b/src/dawn/tests/unittests/CommandAllocatorTests.cpp
index 4f22101..d95bd0c 100644
--- a/src/dawn/tests/unittests/CommandAllocatorTests.cpp
+++ b/src/dawn/tests/unittests/CommandAllocatorTests.cpp
@@ -158,7 +158,7 @@
immediates->size = mySize;
immediates->offset = myOffset;
- Span<uint32_t> values = allocator.AllocateData<uint32_t>(size_t{5u});
+ Span<uint32_t> values = allocator.AllocateData<uint32_t>(size_t{5});
for (size_t i = 0; i < 5; i++) {
values[i] = myValues[i];
}
@@ -176,7 +176,7 @@
ASSERT_EQ(immediates->size, mySize);
ASSERT_EQ(immediates->offset, myOffset);
- Span<const uint32_t> values = iterator.NextData<uint32_t>(size_t{5u});
+ Span<const uint32_t> values = iterator.NextData<uint32_t>(size_t{5});
ASSERT_EQ(values.size(), 5u);
for (auto [i, value] : Enumerate(values)) {
ASSERT_EQ(value, myValues[i]);
diff --git a/src/dawn/tests/unittests/EnumClassBitmasksTests.cpp b/src/dawn/tests/unittests/EnumClassBitmasksTests.cpp
index 7a96d38..2ee3592 100644
--- a/src/dawn/tests/unittests/EnumClassBitmasksTests.cpp
+++ b/src/dawn/tests/unittests/EnumClassBitmasksTests.cpp
@@ -60,7 +60,7 @@
ASSERT_EQ(8u, static_cast<uint32_t>(test3));
Color test4 = ~test3;
- ASSERT_EQ(~uint32_t(8), static_cast<uint32_t>(test4));
+ ASSERT_EQ(~uint32_t{8}, static_cast<uint32_t>(test4));
}
TEST(BitmaskTests, AssignOperations) {
diff --git a/src/dawn/tests/unittests/ITypBitsetTests.cpp b/src/dawn/tests/unittests/ITypBitsetTests.cpp
index d437ad1..484fb91 100644
--- a/src/dawn/tests/unittests/ITypBitsetTests.cpp
+++ b/src/dawn/tests/unittests/ITypBitsetTests.cpp
@@ -66,7 +66,7 @@
ASSERT_FALSE(bits[Key(i)]) << i;
ASSERT_FALSE(bits.test(Key(i))) << i;
} else {
- mask |= (size_t(1) << i);
+ mask |= (size_t{1} << i);
ASSERT_TRUE(bits[Key(i)]) << i;
ASSERT_TRUE(bits.test(Key(i))) << i;
}
diff --git a/src/dawn/tests/unittests/RefCountedTests.cpp b/src/dawn/tests/unittests/RefCountedTests.cpp
index 71a8470..df1ec28 100644
--- a/src/dawn/tests/unittests/RefCountedTests.cpp
+++ b/src/dawn/tests/unittests/RefCountedTests.cpp
@@ -281,7 +281,7 @@
EXPECT_EQ(testDefaultConstructor->GetRefCountPayload(), 0u);
testDefaultConstructor->Release();
- RCTest* testZero = new RCTest(uint64_t(0ull));
+ RCTest* testZero = new RCTest(uint64_t{0});
EXPECT_EQ(testZero->GetRefCountPayload(), 0u);
testZero->Release();
@@ -294,13 +294,13 @@
// Depends on the payload being >= 2 bits.
TEST(Ref, PayloadModifications) {
RCTest* rc = new RCTest(0b10);
- EXPECT_EQ(rc->GetRefCountPayload(), uint64_t(0b10));
+ EXPECT_EQ(rc->GetRefCountPayload(), uint64_t{0b10});
rc->RefCountPayloadFetchOr(0b01);
- EXPECT_EQ(rc->GetRefCountPayload(), uint64_t(0b11));
+ EXPECT_EQ(rc->GetRefCountPayload(), uint64_t{0b11});
rc->RefCountPayloadFetchAnd(0b10);
- EXPECT_EQ(rc->GetRefCountPayload(), uint64_t(0b10));
+ EXPECT_EQ(rc->GetRefCountPayload(), uint64_t{0b10});
rc->Release();
}
diff --git a/src/dawn/tests/unittests/RingBufferAllocatorTests.cpp b/src/dawn/tests/unittests/RingBufferAllocatorTests.cpp
index 74824e0..a31d87b 100644
--- a/src/dawn/tests/unittests/RingBufferAllocatorTests.cpp
+++ b/src/dawn/tests/unittests/RingBufferAllocatorTests.cpp
@@ -64,7 +64,7 @@
size_t offset = 0;
for (ExecutionSerial i(0u); i < ExecutionSerial(maxNumOfFrames); ++i) {
offset = allocator.Allocate(frameSizeInBytes, i);
- ASSERT_EQ(offset, uint64_t(i) * frameSizeInBytes);
+ ASSERT_EQ(offset, uint64_t{i} * frameSizeInBytes);
}
}
diff --git a/src/dawn/tests/unittests/native/CommandBufferEncodingTests.cpp b/src/dawn/tests/unittests/native/CommandBufferEncodingTests.cpp
index febce62..e82a283 100644
--- a/src/dawn/tests/unittests/native/CommandBufferEncodingTests.cpp
+++ b/src/dawn/tests/unittests/native/CommandBufferEncodingTests.cpp
@@ -198,7 +198,7 @@
indirectScratchBuffer = ToAPI(cmd->indirectBuffer.Get());
}
ASSERT_EQ(ToAPI(cmd->indirectBuffer.Get()), indirectScratchBuffer);
- ASSERT_EQ(cmd->indirectOffset, uint64_t(0));
+ ASSERT_EQ(cmd->indirectOffset, uint64_t{0});
};
// Initialize as null. Once we know the pointer, we'll check
diff --git a/src/dawn/tests/unittests/native/LimitsTests.cpp b/src/dawn/tests/unittests/native/LimitsTests.cpp
index b1f3196..4014915 100644
--- a/src/dawn/tests/unittests/native/LimitsTests.cpp
+++ b/src/dawn/tests/unittests/native/LimitsTests.cpp
@@ -379,11 +379,11 @@
{
CombinedLimits limits = defaults;
limits.v1.maxVertexBufferArrayStride = kMaxVertexBufferArrayStride + 1;
- limits.v1.maxColorAttachments = uint32_t(kMaxColorAttachments) + 1;
+ limits.v1.maxColorAttachments = uint32_t{kMaxColorAttachments} + 1;
limits.v1.maxBindGroups = kMaxBindGroups + 1;
limits.v1.maxBindGroupsPlusVertexBuffers = kMaxBindGroupsPlusVertexBuffers + 1;
- limits.v1.maxVertexAttributes = uint32_t(kMaxVertexAttributes) + 1;
- limits.v1.maxVertexBuffers = uint32_t(kMaxVertexBuffers) + 1;
+ limits.v1.maxVertexAttributes = uint32_t{kMaxVertexAttributes} + 1;
+ limits.v1.maxVertexBuffers = uint32_t{kMaxVertexBuffers} + 1;
limits.v1.maxSampledTexturesPerShaderStage = kMaxSampledTexturesPerShaderStage + 1;
limits.v1.maxSamplersPerShaderStage = kMaxSamplersPerShaderStage + 1;
limits.v1.maxStorageBuffersPerShaderStage = kMaxStorageBuffersPerShaderStage + 1;
@@ -394,11 +394,11 @@
NormalizeLimits(&limits);
EXPECT_EQ(limits.v1.maxVertexBufferArrayStride, kMaxVertexBufferArrayStride);
- EXPECT_EQ(limits.v1.maxColorAttachments, uint32_t(kMaxColorAttachments));
+ EXPECT_EQ(limits.v1.maxColorAttachments, uint32_t{kMaxColorAttachments});
EXPECT_EQ(limits.v1.maxBindGroups, kMaxBindGroups);
EXPECT_EQ(limits.v1.maxBindGroupsPlusVertexBuffers, kMaxBindGroupsPlusVertexBuffers);
- EXPECT_EQ(limits.v1.maxVertexAttributes, uint32_t(kMaxVertexAttributes));
- EXPECT_EQ(limits.v1.maxVertexBuffers, uint32_t(kMaxVertexBuffers));
+ EXPECT_EQ(limits.v1.maxVertexAttributes, uint32_t{kMaxVertexAttributes});
+ EXPECT_EQ(limits.v1.maxVertexBuffers, uint32_t{kMaxVertexBuffers});
EXPECT_EQ(limits.v1.maxSampledTexturesPerShaderStage, kMaxSampledTexturesPerShaderStage);
EXPECT_EQ(limits.v1.maxSamplersPerShaderStage, kMaxSamplersPerShaderStage);
EXPECT_EQ(limits.v1.maxStorageBuffersPerShaderStage, kMaxStorageBuffersPerShaderStage);
diff --git a/src/dawn/tests/unittests/native/MemoryInstrumentationTests.cpp b/src/dawn/tests/unittests/native/MemoryInstrumentationTests.cpp
index d4d0057..cde0094 100644
--- a/src/dawn/tests/unittests/native/MemoryInstrumentationTests.cpp
+++ b/src/dawn/tests/unittests/native/MemoryInstrumentationTests.cpp
@@ -334,11 +334,11 @@
// DynamicUploader buffers will still be alive.
MemoryUsageInfo memInfo = ComputeEstimatedMemoryUsageInfo(device.Get());
- EXPECT_GT(memInfo.totalUsage, uint64_t(0));
+ EXPECT_GT(memInfo.totalUsage, uint64_t{0});
ReduceMemoryUsage(device.Get());
// But not any more.
memInfo = ComputeEstimatedMemoryUsageInfo(device.Get());
- EXPECT_EQ(memInfo.totalUsage, uint64_t(0));
+ EXPECT_EQ(memInfo.totalUsage, uint64_t{0});
// Check that DynamicUploader buffer is recreated again.
uniformBuffer = device.CreateBuffer(&kBufferDesc);
@@ -352,7 +352,7 @@
mDeviceMock->GetInstance()->APIProcessEvents();
memInfo = ComputeEstimatedMemoryUsageInfo(device.Get());
- EXPECT_GT(memInfo.totalUsage, uint64_t(0));
+ EXPECT_GT(memInfo.totalUsage, uint64_t{0});
}
// Test the detailed memory usage reported by ComputeEstimatedMemoryUsageInfo()
diff --git a/src/dawn/tests/unittests/native/StreamTests.cpp b/src/dawn/tests/unittests/native/StreamTests.cpp
index c69e357..a03a000 100644
--- a/src/dawn/tests/unittests/native/StreamTests.cpp
+++ b/src/dawn/tests/unittests/native/StreamTests.cpp
@@ -153,9 +153,9 @@
// Only testing explicitly sized types for simplicity, and using 0s for larger types to
// avoid dealing with endianess.
EXPECT_CACHE_KEY_EQ('c', ByteVectorSink({std::byte('c')}));
- EXPECT_CACHE_KEY_EQ(uint8_t(255), ByteVectorSink({std::byte(255)}));
- EXPECT_CACHE_KEY_EQ(uint16_t(0), ByteVectorSink({std::byte(0), std::byte(0)}));
- EXPECT_CACHE_KEY_EQ(uint32_t(0),
+ EXPECT_CACHE_KEY_EQ(uint8_t{255}, ByteVectorSink({std::byte(255)}));
+ EXPECT_CACHE_KEY_EQ(uint16_t{0}, ByteVectorSink({std::byte(0), std::byte(0)}));
+ EXPECT_CACHE_KEY_EQ(uint32_t{0},
ByteVectorSink({std::byte(0), std::byte(0), std::byte(0), std::byte(0)}));
}
@@ -185,7 +185,7 @@
std::string str = "string";
ByteVectorSink expected;
- StreamIn(&expected, size_t(6));
+ StreamIn(&expected, size_t{6});
auto strBytes = std::as_bytes(std::span(str));
expected.insert(expected.end(), strBytes.begin(), strBytes.end());
@@ -211,7 +211,7 @@
static constexpr std::string_view str("string");
ByteVectorSink expected;
- StreamIn(&expected, size_t(6));
+ StreamIn(&expected, size_t{6});
auto strBytes = std::as_bytes(std::span(str));
expected.insert(expected.end(), strBytes.begin(), strBytes.end());
@@ -284,9 +284,9 @@
std::string_view s = "hi!";
ByteVectorSink expected;
- StreamIn(&expected, s, uint32_t(42));
+ StreamIn(&expected, s, uint32_t{42});
- EXPECT_CACHE_KEY_EQ(std::make_pair(s, uint32_t(42)), expected);
+ EXPECT_CACHE_KEY_EQ(std::make_pair(s, uint32_t{42}), expected);
}
// Test that ByteVectorSink serializes std::optional as expected.
@@ -315,14 +315,14 @@
// Type id of std::string_view is 0 in VariantType
VariantType v1 = stringViewInput;
ByteVectorSink expected;
- StreamIn(&expected, /* Type id */ size_t(0), stringViewInput);
+ StreamIn(&expected, /* Type id */ size_t{0}, stringViewInput);
EXPECT_CACHE_KEY_EQ(v1, expected);
}
{
// Type id of uint32_t is 1 in VariantType
VariantType v2 = u32Input;
ByteVectorSink expected;
- StreamIn(&expected, /* Type id */ size_t(1), u32Input);
+ StreamIn(&expected, /* Type id */ size_t{1}, u32Input);
EXPECT_CACHE_KEY_EQ(v2, expected);
}
}
@@ -371,9 +371,9 @@
// Expect the number of entries, followed by (K, V) pairs sorted in order of key.
ByteVectorSink expected;
- StreamIn(&expected, size_t(4), std::make_pair(uint32_t(1), m[1]),
- std::make_pair(uint32_t(3), m[3]), std::make_pair(uint32_t(4), m[4]),
- std::make_pair(uint32_t(7), m[7]));
+ StreamIn(&expected, size_t{4}, std::make_pair(uint32_t{1}, m[1]),
+ std::make_pair(uint32_t{3}, m[3]), std::make_pair(uint32_t{4}, m[4]),
+ std::make_pair(uint32_t{7}, m[7]));
EXPECT_CACHE_KEY_EQ(m, expected);
}
@@ -384,7 +384,7 @@
// Expect the number of entries, followed by values sorted in order of key.
ByteVectorSink expected;
- StreamIn(&expected, size_t(4), 1, 4, 6, 99);
+ StreamIn(&expected, size_t{4}, 1, 4, 6, 99);
EXPECT_CACHE_KEY_EQ(input, expected);
}
@@ -414,9 +414,9 @@
// Expect the number of entries, followed by (K, V) pairs sorted in order of key.
ByteVectorSink expected;
- StreamIn(&expected, size_t(4), std::make_pair(uint32_t(1), m[1]),
- std::make_pair(uint32_t(3), m[3]), std::make_pair(uint32_t(4), m[4]),
- std::make_pair(uint32_t(7), m[7]));
+ StreamIn(&expected, size_t{4}, std::make_pair(uint32_t{1}, m[1]),
+ std::make_pair(uint32_t{3}, m[3]), std::make_pair(uint32_t{4}, m[4]),
+ std::make_pair(uint32_t{7}, m[7]));
EXPECT_CACHE_KEY_EQ(m, expected);
}
@@ -427,7 +427,7 @@
// Expect the number of entries, followed by values sorted in order of key.
ByteVectorSink expected;
- StreamIn(&expected, size_t(4), 1, 4, 6, 99);
+ StreamIn(&expected, size_t{4}, 1, 4, 6, 99);
EXPECT_CACHE_KEY_EQ(input, expected);
}
@@ -437,7 +437,7 @@
tint::BindingPoint bp{3, 6};
ByteVectorSink expected;
- StreamIn(&expected, uint32_t(3), uint32_t(6));
+ StreamIn(&expected, uint32_t{3}, uint32_t{6});
EXPECT_CACHE_KEY_EQ(bp, expected);
}
@@ -448,7 +448,7 @@
ByteVectorSink expected;
// The second UnsafeUnserializedValue<uint32_t> is not serialized.
- StreamIn(&expected, uint32_t(123));
+ StreamIn(&expected, uint32_t{123});
EXPECT_CACHE_KEY_EQ(input, expected);
}
diff --git a/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp b/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp
index 40c414a..0fbcf82 100644
--- a/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp
+++ b/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp
@@ -1138,7 +1138,7 @@
// Error case, offset+size overflows to be 0
ASSERT_DEVICE_ERROR(
- utils::MakeBindGroup(device, layout, {{0, buffer, 256, uint32_t(0) - uint32_t(256)}}));
+ utils::MakeBindGroup(device, layout, {{0, buffer, 256, uint32_t{0} - uint32_t{256}}}));
}
// Tests constraints to be sure the uniform buffer binding isn't too large
diff --git a/src/dawn/tests/unittests/validation/BufferValidationTests.cpp b/src/dawn/tests/unittests/validation/BufferValidationTests.cpp
index 397f20c..551fa2e 100644
--- a/src/dawn/tests/unittests/validation/BufferValidationTests.cpp
+++ b/src/dawn/tests/unittests/validation/BufferValidationTests.cpp
@@ -336,7 +336,7 @@
// Error case, offset + size is larger than the buffer, overflow case.
{
wgpu::Buffer buffer = CreateBuffer(12);
- AssertMapAsyncError(buffer, GetParam(), 8, std::numeric_limits<size_t>::max() & ~size_t(7));
+ AssertMapAsyncError(buffer, GetParam(), 8, std::numeric_limits<size_t>::max() & ~size_t{7});
}
// The same tests, with an unmap before destroying the buffer.
@@ -375,7 +375,7 @@
wgpu::Buffer buffer = CreateBuffer(12);
EXPECT_CALL(mockCb, Call(wgpu::MapAsyncStatus::Error, _)).Times(1);
ASSERT_DEVICE_ERROR(
- buffer.MapAsync(GetParam(), 8, std::numeric_limits<size_t>::max() & ~size_t(7),
+ buffer.MapAsync(GetParam(), 8, std::numeric_limits<size_t>::max() & ~size_t{7},
wgpu::CallbackMode::AllowSpontaneous, mockCb.Callback()));
buffer.Unmap();
}
@@ -672,7 +672,7 @@
// Test that if CreateBuffer OOMs while mapping at creation, it returns null.
TEST_F(BufferValidationTest, MappedAtCreationOOM) {
- uint64_t kStupidLarge = uint64_t(1) << uint64_t(63);
+ uint64_t kStupidLarge = uint64_t{1} << uint64_t{63};
// Buffer would fail validation due to invalid usage combination
{
diff --git a/src/dawn/tests/unittests/validation/PixelLocalStorageTests.cpp b/src/dawn/tests/unittests/validation/PixelLocalStorageTests.cpp
index 941a358..4ec3501 100644
--- a/src/dawn/tests/unittests/validation/PixelLocalStorageTests.cpp
+++ b/src/dawn/tests/unittests/validation/PixelLocalStorageTests.cpp
@@ -533,7 +533,7 @@
// Check that overflows don't incorrectly pass the validation.
{
- PLSSpec spec = {4, {{uint64_t(0) - uint64_t(4), wgpu::TextureFormat::R32Uint}}};
+ PLSSpec spec = {4, {{uint64_t{0} - uint64_t{4}, wgpu::TextureFormat::R32Uint}}};
ASSERT_DEVICE_ERROR(MakePipelineLayout(spec));
ASSERT_DEVICE_ERROR(RecordPLSRenderPass(spec));
}
diff --git a/src/dawn/tests/white_box/QueryInternalShaderTests.cpp b/src/dawn/tests/white_box/QueryInternalShaderTests.cpp
index a5a64aa..86d986e 100644
--- a/src/dawn/tests/white_box/QueryInternalShaderTests.cpp
+++ b/src/dawn/tests/white_box/QueryInternalShaderTests.cpp
@@ -89,7 +89,7 @@
// Quantization may make an actual value close to the lower limit go below it.
// Take this into account by also quantizing the lower limit.
uint32_t invertedQuantizationMask = ~mQuantizationMask;
- uint64_t quantizationMask64 = ~uint64_t(invertedQuantizationMask);
+ uint64_t quantizationMask64 = ~uint64_t{invertedQuantizationMask};
lowerLimit &= quantizationMask64;
if (DAWN_UNSAFE_TODO(actual[i]) < lowerLimit ||
diff --git a/src/emdawnwebgpu/tests/SpotTests.cpp b/src/emdawnwebgpu/tests/SpotTests.cpp
index 16415e2..8720f73 100644
--- a/src/emdawnwebgpu/tests/SpotTests.cpp
+++ b/src/emdawnwebgpu/tests/SpotTests.cpp
@@ -462,7 +462,7 @@
readback.Unmap();
}),
UINT64_MAX);
- EXPECT_EQ(result, uint32_t(0xff00ff00)); // ABGR
+ EXPECT_EQ(result, uint32_t{0xff00ff00}); // ABGR
EM_ASM({
// VideoFrames should always be closed manually.
diff --git a/src/tint/lang/wgsl/ast/builder.h b/src/tint/lang/wgsl/ast/builder.h
index 0baa97f..5f51d0a 100644
--- a/src/tint/lang/wgsl/ast/builder.h
+++ b/src/tint/lang/wgsl/ast/builder.h
@@ -954,7 +954,7 @@
Expression* expr = nullptr;
return array(source, Of<T>(), expr);
} else {
- return array(source, Of<T>(), uint32_t(N));
+ return array(source, Of<T>(), uint32_t{N});
}
}
@@ -965,7 +965,7 @@
static_assert(N == 0, "arrays with a count cannot be inferred");
return array();
} else {
- return array(Of<T>(), uint32_t(N));
+ return array(Of<T>(), uint32_t{N});
}
}
diff --git a/src/tint/lang/wgsl/reader/parser/lexer.cc b/src/tint/lang/wgsl/reader/parser/lexer.cc
index 0d611a5..5286ecf 100644
--- a/src/tint/lang/wgsl/reader/parser/lexer.cc
+++ b/src/tint/lang/wgsl/reader/parser/lexer.cc
@@ -867,7 +867,7 @@
}
// Check the low 52-valid_mantissa_bits mantissa bits must be 0.
TINT_ASSERT((0 <= valid_mantissa_bits) && (valid_mantissa_bits <= 23));
- if (result_u64 & ((uint64_t(1) << (52 - valid_mantissa_bits)) - 1)) {
+ if (result_u64 & ((uint64_t{1} << (52 - valid_mantissa_bits)) - 1)) {
return Token{Token::Type::kError, source,
"value cannot be exactly represented as 'f32'"};
}
@@ -920,7 +920,7 @@
}
// Check the low 52-valid_mantissa_bits mantissa bits must be 0.
TINT_ASSERT((0 <= valid_mantissa_bits) && (valid_mantissa_bits <= 10));
- if (result_u64 & ((uint64_t(1) << (52 - valid_mantissa_bits)) - 1)) {
+ if (result_u64 & ((uint64_t{1} << (52 - valid_mantissa_bits)) - 1)) {
return Token{Token::Type::kError, source,
"value cannot be exactly represented as 'f16'"};
}
diff --git a/src/tint/lang/wgsl/resolver/eval_test.h b/src/tint/lang/wgsl/resolver/eval_test.h
index b9eae3b..0312559 100644
--- a/src/tint/lang/wgsl/resolver/eval_test.h
+++ b/src/tint/lang/wgsl/resolver/eval_test.h
@@ -53,13 +53,13 @@
using ConstEvalTestWithParam = resolver::ResolverTestWithParam<T>;
template <typename T>
-inline const auto kPiOver2 = T(UnwrapNumber<T>(1.57079632679489661923));
+inline const auto kPiOver2 = T{static_cast<UnwrapNumber<T>>(1.57079632679489661923)};
template <typename T>
-inline const auto kPiOver4 = T(UnwrapNumber<T>(0.785398163397448309616));
+inline const auto kPiOver4 = T{static_cast<UnwrapNumber<T>>(0.785398163397448309616)};
template <typename T>
-inline const auto k3PiOver4 = T(UnwrapNumber<T>(2.356194490192344928846));
+inline const auto k3PiOver4 = T{static_cast<UnwrapNumber<T>>(2.356194490192344928846)};
/// Walks the constant::Value @p c, accumulating all the inner-most scalar values into @p args
template <size_t N>
diff --git a/src/utils/heap_array_test.cc b/src/utils/heap_array_test.cc
index 7f9df35..c58f704 100644
--- a/src/utils/heap_array_test.cc
+++ b/src/utils/heap_array_test.cc
@@ -193,7 +193,7 @@
static_assert(std::is_same_v<decltype(data), int*>);
static_assert(std::is_same_v<decltype(size), size_t>); // Not an Index!
ASSERT_EQ(data, originalData);
- ASSERT_EQ(size, size_t(originalSize));
+ ASSERT_EQ(size, size_t{originalSize});
delete[] data;
}