Fix implicit widening issues in multiplications This CL fixes the violations found by enabling `bugprone-implicit-widening-of-multiplication-result` in clang-tidy and enables the check in .clang-tidy. Bug: 515563723 Change-Id: Ic50de44b16d8bdf002eafb612615a94e6b27674d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/324416 Reviewed-by: dan sinclair <dsinclair@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
diff --git a/.clang-tidy b/.clang-tidy index 6635ba0..c7d0dad 100644 --- a/.clang-tidy +++ b/.clang-tidy
@@ -32,7 +32,6 @@ - -bugprone-easily-swappable-parameters - -bugprone-forward-declaration-namespace - -bugprone-forwarding-reference-overload - - -bugprone-implicit-widening-of-multiplication-result - -bugprone-infinite-loop - -bugprone-integer-division - -bugprone-lambda-function-name
diff --git a/src/dawn/common/Sha3.h b/src/dawn/common/Sha3.h index af87dc7..43f09a2 100644 --- a/src/dawn/common/Sha3.h +++ b/src/dawn/common/Sha3.h
@@ -41,7 +41,7 @@ // string of bits it is in the order defined for S in FIPS 202. When accessed as a state, // A[x, y, z] is the z-th bit of element x + 5y. using Sha3Lane = uint64_t; -static_assert(25 * 8 * sizeof(Sha3Lane) == 1600); +static_assert(25ULL * 8 * sizeof(Sha3Lane) == 1600); using Sha3State = std::array<Sha3Lane, 25>; static_assert(sizeof(Sha3State) == 25 * sizeof(Sha3Lane), "Sha3State must be packed.");
diff --git a/src/dawn/common/SlabAllocator.cpp b/src/dawn/common/SlabAllocator.cpp index 40b4b02..97983f5 100644 --- a/src/dawn/common/SlabAllocator.cpp +++ b/src/dawn/common/SlabAllocator.cpp
@@ -78,7 +78,8 @@ mIndexLinkNodeOffset(Align(objectSize, alignof(IndexLinkNode))), mBlockStride(Align(mIndexLinkNodeOffset + u32_sizeof<IndexLinkNode>, objectAlignment)), mBlocksPerSlab(blocksPerSlab), - mTotalAllocationSize(static_cast<size_t>(mSlabBlocksOffset) + mBlocksPerSlab * mBlockStride) { + mTotalAllocationSize(static_cast<size_t>(mSlabBlocksOffset) + + static_cast<size_t>(mBlocksPerSlab) * mBlockStride) { DAWN_ASSERT(blocksPerSlab > 0); DAWN_ASSERT(IsPowerOfTwo(mAllocationAlignment)); }
diff --git a/src/dawn/fuzzers/DawnWireServerFuzzer.cpp b/src/dawn/fuzzers/DawnWireServerFuzzer.cpp index 24d44b1..a98a88a 100644 --- a/src/dawn/fuzzers/DawnWireServerFuzzer.cpp +++ b/src/dawn/fuzzers/DawnWireServerFuzzer.cpp
@@ -50,7 +50,7 @@ public: size_t GetMaximumAllocationSize() const override { // Some fuzzer bots have a 2GB allocation limit. Pick a value reasonably below that. - return 1024 * 1024 * 1024; + return 1024ULL * 1024 * 1024; } void* GetCmdSpace(size_t size) override { if (size > buf.size()) {
diff --git a/src/dawn/native/BlitBufferToTexture.cpp b/src/dawn/native/BlitBufferToTexture.cpp index ba71f43..2d98d61 100644 --- a/src/dawn/native/BlitBufferToTexture.cpp +++ b/src/dawn/native/BlitBufferToTexture.cpp
@@ -458,8 +458,8 @@ DAWN_TRY_ASSIGN(dstView, dst.texture->CreateView(&viewDesc)); } - const uint64_t srcOffset = - src.offset + dchecked_cast<uint32_t>(z) * src.rowsPerImage * src.bytesPerRow; + const uint64_t srcOffset = src.offset + static_cast<uint64_t>(dchecked_cast<uint32_t>(z)) * + src.rowsPerImage * src.bytesPerRow; const uint64_t srcBufferBindingOffset = AlignDown(srcOffset, ssboAlignment); const uint32_t shaderReadOffset = static_cast<uint32_t>(srcOffset & (ssboAlignment - 1)); Ref<BufferBase> paramsBuffer;
diff --git a/src/dawn/native/BlitTextureToBuffer.cpp b/src/dawn/native/BlitTextureToBuffer.cpp index f617d0a..f37b12f 100644 --- a/src/dawn/native/BlitTextureToBuffer.cpp +++ b/src/dawn/native/BlitTextureToBuffer.cpp
@@ -1138,13 +1138,13 @@ switch (bytesPerTexel) { case 1: // One thread is responsible for writing four texel values (x, y) ~ (x+3, y). - workgroupCountX = - Align(texelCopyWidth, 4 * kWorkgroupSizeX) / (4 * kWorkgroupSizeX); + workgroupCountX = Align(texelCopyWidth, static_cast<size_t>(4) * kWorkgroupSizeX) / + (static_cast<size_t>(4) * kWorkgroupSizeX); break; case 2: // One thread is responsible for writing two texel values (x, y) and (x+1, y). - workgroupCountX = - Align(texelCopyWidth, 2 * kWorkgroupSizeX) / (2 * kWorkgroupSizeX); + workgroupCountX = Align(texelCopyWidth, static_cast<size_t>(2) * kWorkgroupSizeX) / + (static_cast<size_t>(2) * kWorkgroupSizeX); break; case 4: case 8:
diff --git a/src/dawn/native/DynamicUploader.cpp b/src/dawn/native/DynamicUploader.cpp index 64b37ea..396d453 100644 --- a/src/dawn/native/DynamicUploader.cpp +++ b/src/dawn/native/DynamicUploader.cpp
@@ -40,7 +40,7 @@ namespace dawn::native { namespace { -constexpr uint64_t kRingBufferSize = 4 * 1024 * 1024; +constexpr uint64_t kRingBufferSize = 4ULL * 1024 * 1024; } // anonymous namespace DynamicUploader::DynamicUploader(DeviceBase* device) : mDevice(device) {} @@ -138,7 +138,7 @@ } MaybeError DynamicUploader::MaybeSubmitPendingCommands() { - constexpr uint64_t kPendingMemorySubmitThreshold = 16 * 1024 * 1024; + constexpr uint64_t kPendingMemorySubmitThreshold = 16ULL * 1024 * 1024; if (mMemoryPendingSubmit.load(std::memory_order_relaxed) < kPendingMemorySubmitThreshold) { return {}; }
diff --git a/src/dawn/native/IndirectDrawValidationEncoder.cpp b/src/dawn/native/IndirectDrawValidationEncoder.cpp index 783db5e..79e9ffb 100644 --- a/src/dawn/native/IndirectDrawValidationEncoder.cpp +++ b/src/dawn/native/IndirectDrawValidationEncoder.cpp
@@ -423,7 +423,7 @@ } size_t GetBatchDataSize(uint32_t numDraws) { - return sizeof(BatchInfo) + (numDraws * kIndirectDrawByteSize); + return sizeof(BatchInfo) + (static_cast<size_t>(numDraws) * kIndirectDrawByteSize); } } // namespace @@ -596,7 +596,7 @@ continue; } outputParamsSizeForMultiDraw += - draw.cmd->maxDrawCount * + static_cast<uint64_t>(draw.cmd->maxDrawCount) * GetOutputIndirectDrawSize(draw.type, draw.duplicateBaseVertexInstance); outputParamsSizeForMultiDraw = Align(outputParamsSizeForMultiDraw, minStorageBufferOffsetAlignment); @@ -834,7 +834,7 @@ outputParamsBinding.buffer = outputParamsBuffer.GetBuffer(); outputParamsBinding.offset = outputOffset; outputParamsBinding.size = - draw.cmd->maxDrawCount * + static_cast<uint64_t>(draw.cmd->maxDrawCount) * GetOutputIndirectDrawSize(draw.type, draw.duplicateBaseVertexInstance); if (cmd->drawCountBuffer != nullptr) { @@ -883,7 +883,7 @@ cmd->indirectOffset = outputOffset; // Proceed to the next output offset. - outputOffset += cmd->maxDrawCount * + outputOffset += static_cast<uint64_t>(cmd->maxDrawCount) * GetOutputIndirectDrawSize(draw.type, draw.duplicateBaseVertexInstance); outputOffset = Align(outputOffset, minStorageBufferOffsetAlignment); }
diff --git a/src/dawn/native/Pipeline.cpp b/src/dawn/native/Pipeline.cpp index f5d0421..af24fbf 100644 --- a/src/dawn/native/Pipeline.cpp +++ b/src/dawn/native/Pipeline.cpp
@@ -28,6 +28,7 @@ #include "src/dawn/native/Pipeline.h" #include <algorithm> +#include <cstddef> #include <set> #include <utility> @@ -78,12 +79,12 @@ } // count the number of non-sampled that are not referenced by sampled pairs. - auto numNonSampled = sign_cast(std::count_if( + uint32_t numNonSampled = sign_cast(std::count_if( nonSampled.begin(), nonSampled.end(), [&](const WGSLBindPoint& nonSampledBindingPoint) { return !sampledTextures.contains(nonSampledBindingPoint); })); return numSamplerTexturePairs + numNonSampled + numSamplerExternalTexturePairs * 3 + - uint32_t(sampledExternalTextures.size()); + static_cast<uint32_t>(sampledExternalTextures.size()); } } // namespace
diff --git a/src/dawn/native/SubresourceStorage.h b/src/dawn/native/SubresourceStorage.h index 8707f6a..472bad9 100644 --- a/src/dawn/native/SubresourceStorage.h +++ b/src/dawn/native/SubresourceStorage.h
@@ -497,8 +497,8 @@ DAWN_ASSERT(!mLayerCompressed); uint32_t aspectCount = GetAspectCount(mAspects); - mLayerCompressed = HeapArray<bool>{aspectCount * mArrayLayerCount}; - mData = HeapArray<T>{aspectCount * mArrayLayerCount * mMipLevelCount}; + mLayerCompressed = HeapArray<bool>{static_cast<size_t>(aspectCount) * mArrayLayerCount}; + mData = HeapArray<T>{static_cast<size_t>(aspectCount) * mArrayLayerCount * mMipLevelCount}; for (uint32_t layerIndex = 0; layerIndex < aspectCount * mArrayLayerCount; layerIndex++) { mLayerCompressed[layerIndex] = true;
diff --git a/src/dawn/native/Texture.cpp b/src/dawn/native/Texture.cpp index 91eb7ae..2df68e4 100644 --- a/src/dawn/native/Texture.cpp +++ b/src/dawn/native/Texture.cpp
@@ -1601,8 +1601,8 @@ const AspectInfo& info = mFormat->GetAspectInfo(aspect); for (uint32_t i = 0; i < mMipLevelCount; i++) { Extent3D mipSize = GetMipLevelSingleSubresourcePhysicalSize(i, aspect); - byteSize += (mipSize.width / info.block.width) * (mipSize.height / info.block.height) * - info.block.byteSize * mSampleCount; + byteSize += static_cast<uint64_t>(mipSize.width / info.block.width) * + (mipSize.height / info.block.height) * info.block.byteSize * mSampleCount; } } if (mDimension == wgpu::TextureDimension::e2D) {
diff --git a/src/dawn/native/d3d11/BufferD3D11.cpp b/src/dawn/native/d3d11/BufferD3D11.cpp index 0294b60..937ec57 100644 --- a/src/dawn/native/d3d11/BufferD3D11.cpp +++ b/src/dawn/native/d3d11/BufferD3D11.cpp
@@ -55,7 +55,7 @@ namespace { // Max size for a CPU buffer. -constexpr uint64_t kMaxCPUUploadBufferSize = 64 * 1024; +constexpr uint64_t kMaxCPUUploadBufferSize = 64ULL * 1024; constexpr wgpu::BufferUsage kCopyUsages = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst | kInternalCopySrcBuffer;
diff --git a/src/dawn/native/d3d11/DeviceD3D11.cpp b/src/dawn/native/d3d11/DeviceD3D11.cpp index 6214b2e..6d35ccc 100644 --- a/src/dawn/native/d3d11/DeviceD3D11.cpp +++ b/src/dawn/native/d3d11/DeviceD3D11.cpp
@@ -631,7 +631,7 @@ ResultOrError<Ref<BufferBase>> Device::GetStagingBuffer( const ScopedCommandRecordingContext* commandContext, uint64_t size) { - constexpr uint64_t kMinStagingBufferSize = 4 * 1024; + constexpr uint64_t kMinStagingBufferSize = 4ULL * 1024; uint64_t bufferSize = Align(size, kMinStagingBufferSize); BufferDescriptor descriptor; descriptor.usage = wgpu::BufferUsage::MapWrite | wgpu::BufferUsage::CopySrc; @@ -667,7 +667,7 @@ mTotalStagingBufferSize += bufferSize; // Purge the old staging buffers if the total size is too large. - constexpr uint64_t kMaxTotalSize = 16 * 1024 * 1024; + constexpr uint64_t kMaxTotalSize = 16ULL * 1024 * 1024; for (auto it = mStagingBuffers.begin(); it != mStagingBuffers.end() && mTotalStagingBufferSize > kMaxTotalSize && (*it)->GetLastUsageSerial() <= completedSerial;) {
diff --git a/src/dawn/native/d3d11/DeviceD3D11.h b/src/dawn/native/d3d11/DeviceD3D11.h index 1123fb1..ab327c4 100644 --- a/src/dawn/native/d3d11/DeviceD3D11.h +++ b/src/dawn/native/d3d11/DeviceD3D11.h
@@ -133,7 +133,7 @@ const UnpackedPtr<DeviceDescriptor>& descriptor, const TogglesState& deviceToggles, Ref<DeviceBase::DeviceLostEvent>&& lostEvent); - static constexpr uint64_t kMaxStagingBufferSize = 512 * 1024; + static constexpr uint64_t kMaxStagingBufferSize = 512ULL * 1024; ResultOrError<Ref<BindGroupBase>> CreateBindGroupImpl( const UnpackedPtr<BindGroupDescriptor>& descriptor) override;
diff --git a/src/dawn/native/d3d11/TextureD3D11.cpp b/src/dawn/native/d3d11/TextureD3D11.cpp index b05447d..578375c 100644 --- a/src/dawn/native/d3d11/TextureD3D11.cpp +++ b/src/dawn/native/d3d11/TextureD3D11.cpp
@@ -744,6 +744,8 @@ bool writeCompleteTexture = isCompleteSubresourceCopiedTo && GetNumMipLevels() == 1 && GetArrayLayers() == subresources.layerCount; + uint32_t bytesPerImage = bytesPerRow * rowsPerImage; + if (GetDimension() == wgpu::TextureDimension::e3D) { dstBox.front = origin.z; dstBox.back = origin.z + size.depthOrArrayLayers; @@ -751,7 +753,7 @@ GetSubresourceIndex(subresources.baseMipLevel, 0, D3D11Aspect(subresources.aspects)); UINT copyFlag = writeCompleteTexture ? D3D11_COPY_DISCARD : 0; commandContext->UpdateSubresource1(GetD3D11Resource(), subresource, &dstBox, data, - bytesPerRow, bytesPerRow * rowsPerImage, copyFlag); + bytesPerRow, bytesPerImage, copyFlag); } else { dstBox.front = 0; dstBox.back = 1; @@ -763,7 +765,7 @@ UINT copyFlag = (writeCompleteTexture && layer == 0) ? D3D11_COPY_DISCARD : 0; commandContext->UpdateSubresource1(GetD3D11Resource(), subresource, pDstBox, data, bytesPerRow, 0, copyFlag); - DAWN_UNSAFE_TODO(data += rowsPerImage * bytesPerRow); + DAWN_UNSAFE_TODO(data += bytesPerImage); } } @@ -892,7 +894,7 @@ "D3D11 map staging texture")); uint8_t* pSrcData = static_cast<uint8_t*>(mappedResource.pData); - uint64_t dstOffset = dstBytesPerRow * dstRowsPerImage * layer; + uint64_t dstOffset = static_cast<uint64_t>(dstBytesPerRow) * dstRowsPerImage * layer; if (dstBytesPerRow == bytesPerRow && mappedResource.RowPitch == bytesPerRow) { // If there is no padding in the rows, we can upload the whole image // in one read. @@ -940,7 +942,7 @@ "D3D11 map staging texture")); for (uint32_t z = 0; z < size.depthOrArrayLayers; ++z) { - uint64_t dstOffset = dstBytesPerRow * dstRowsPerImage * z; + uint64_t dstOffset = static_cast<uint64_t>(dstBytesPerRow) * dstRowsPerImage * z; uint8_t* pSrcData = DAWN_UNSAFE_TODO(static_cast<uint8_t*>(mappedResource.pData) + z * mappedResource.DepthPitch); if (dstBytesPerRow == bytesPerRow && mappedResource.RowPitch == bytesPerRow) {
diff --git a/src/dawn/native/d3d12/DeviceD3D12.cpp b/src/dawn/native/d3d12/DeviceD3D12.cpp index 5827478..fdb5d19 100644 --- a/src/dawn/native/d3d12/DeviceD3D12.cpp +++ b/src/dawn/native/d3d12/DeviceD3D12.cpp
@@ -74,7 +74,7 @@ static constexpr uint8_t kAttachmentDescriptorHeapSize = 64; // Value may change in the future to better accommodate large clears. -static constexpr uint64_t kZeroBufferSize = 1024 * 1024 * 4; // 4 Mb +static constexpr uint64_t kZeroBufferSize = 1024ULL * 1024 * 4; // 4 Mb static constexpr uint64_t kMaxDebugMessagesToPrint = 5; } // namespace
diff --git a/src/dawn/native/d3d12/ResourceAllocatorManagerD3D12.cpp b/src/dawn/native/d3d12/ResourceAllocatorManagerD3D12.cpp index 9c87a95..c3e828d 100644 --- a/src/dawn/native/d3d12/ResourceAllocatorManagerD3D12.cpp +++ b/src/dawn/native/d3d12/ResourceAllocatorManagerD3D12.cpp
@@ -229,7 +229,7 @@ } uint32_t tileWidth = kTileSize / tileHeight; - uint64_t layerxSamples = arrayLayerCount * sampleCount; + uint64_t layerxSamples = static_cast<uint64_t>(arrayLayerCount) * sampleCount; if (layerxSamples <= 1) { return 0; @@ -237,7 +237,7 @@ uint32_t columnPitch = GetColumnPitch(height, mipLevelCount); - uint64_t totalWidth = width * colorFormatBytesPerBlock; + uint64_t totalWidth = static_cast<uint64_t>(width) * colorFormatBytesPerBlock; uint64_t totalHeight = columnPitch * layerxSamples; // Texture should be aligned on both tile width (512 bytes) and tile height (128 rows) on Intel
diff --git a/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp b/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp index 422fa7c..96003b4 100644 --- a/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp +++ b/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp
@@ -166,7 +166,7 @@ // The size in bytes of a descriptor heap is best calculated by the increment size // multiplied by the number of descriptors. In practice, this is only an estimate and // the actual size may vary depending on the driver. - const uint64_t kSize = mSizeIncrement * descriptorCount; + const uint64_t kSize = static_cast<uint64_t>(mSizeIncrement) * descriptorCount; DAWN_TRY(mDevice->GetResidencyManager()->EnsureCanAllocate(kSize, MemorySegment::Local));
diff --git a/src/dawn/native/null/DeviceNull.cpp b/src/dawn/native/null/DeviceNull.cpp index 21acd10..8e17c43 100644 --- a/src/dawn/native/null/DeviceNull.cpp +++ b/src/dawn/native/null/DeviceNull.cpp
@@ -120,7 +120,7 @@ auto* heapInfo = new MemoryHeapInfo[1]; memoryHeapProperties->heapInfo = DAWN_UNSAFE_TODO({heapInfo, 1}); - heapInfo[0].size = 1024 * 1024 * 1024; + heapInfo[0].size = 1024ULL * 1024 * 1024; heapInfo[0].properties = wgpu::HeapProperty::DeviceLocal | wgpu::HeapProperty::HostVisible | wgpu::HeapProperty::HostCached; }
diff --git a/src/dawn/native/null/DeviceNull.h b/src/dawn/native/null/DeviceNull.h index fd21340..6543350 100644 --- a/src/dawn/native/null/DeviceNull.h +++ b/src/dawn/native/null/DeviceNull.h
@@ -181,7 +181,7 @@ std::vector<std::unique_ptr<PendingOperation>> mPendingOperations; - static constexpr uint64_t kMaxMemoryUsage = 512 * 1024 * 1024; + static constexpr uint64_t kMaxMemoryUsage = 512ULL * 1024 * 1024; size_t mMemoryUsage = 0; };
diff --git a/src/dawn/native/opengl/CommandBufferGL.cpp b/src/dawn/native/opengl/CommandBufferGL.cpp index 65f0e79..5fac0c8 100644 --- a/src/dawn/native/opengl/CommandBufferGL.cpp +++ b/src/dawn/native/opengl/CommandBufferGL.cpp
@@ -1470,8 +1470,9 @@ DAWN_TRY(immediates.Apply(gl)); DAWN_GL_TRY(gl, DrawElementsInstanced( topology, draw->indexCount, indexBufferFormat, - reinterpret_cast<void*>(draw->firstIndex * indexFormatSize + - indexBufferBaseOffset), + reinterpret_cast<void*>( + static_cast<uint64_t>(draw->firstIndex) * indexFormatSize + + indexBufferBaseOffset), draw->instanceCount)); break; } @@ -1736,7 +1737,8 @@ DAWN_GL_TRY(gl, BindTexture(target, texture->GetTextureHandle())); const TypedTexelBlockInfo& blockInfo = GetBlockInfo(destination); const BlockExtent3D blockCopySize = blockInfo.ToBlock(copySize); - const uint64_t bytesPerImage = dataLayout.rowsPerImage * dataLayout.bytesPerRow; + const uint64_t bytesPerImage = + static_cast<uint64_t>(dataLayout.rowsPerImage) * dataLayout.bytesPerRow; const BlockCount rowsPerImage{dataLayout.rowsPerImage}; // Note: bytesPerRow is not necessarily a multiple of block size because WriteTexture is // directly implemented by the GL backend and doesn't have alignment constraints for
diff --git a/src/dawn/native/webgpu/CaptureContext.h b/src/dawn/native/webgpu/CaptureContext.h index ffb14f6..b1299f3 100644 --- a/src/dawn/native/webgpu/CaptureContext.h +++ b/src/dawn/native/webgpu/CaptureContext.h
@@ -88,7 +88,7 @@ raw_ref<CaptureContext> mContext; }; - static constexpr uint64_t kCopyBufferSize = 1024 * 1024; + static constexpr uint64_t kCopyBufferSize = 1024ULL * 1024; // Add resources both, creates an id for the resource AND captures its // description if it has not already been captured which is effectively
diff --git a/src/dawn/native/webgpu/TextureWGPU.cpp b/src/dawn/native/webgpu/TextureWGPU.cpp index 0260738..cf3074c 100644 --- a/src/dawn/native/webgpu/TextureWGPU.cpp +++ b/src/dawn/native/webgpu/TextureWGPU.cpp
@@ -315,7 +315,7 @@ // We only write out the beginning of each row, the rest is padding. for (BlockCount blockRow{0u}; blockRow < blockRows; ++blockRow) { const void* data = wgpu->bufferGetConstMappedRange( - copyBuffer, dchecked_cast<uint32_t>(blockRow) * alignedBytesPerRow, + copyBuffer, static_cast<size_t>(dchecked_cast<uint32_t>(blockRow)) * alignedBytesPerRow, mappableBytesPerRow); writer.WriteContentBytes(data, usedBytesPerRow); }
diff --git a/src/dawn/replay/BlitBufferToDepthTexture.cpp b/src/dawn/replay/BlitBufferToDepthTexture.cpp index ae97ffc..b4ad14e 100644 --- a/src/dawn/replay/BlitBufferToDepthTexture.cpp +++ b/src/dawn/replay/BlitBufferToDepthTexture.cpp
@@ -160,7 +160,8 @@ dstView = dst.texture.CreateView(&viewDesc); } - const uint64_t srcOffset = src.offset + z * src.rowsPerImage * src.bytesPerRow; + const uint64_t srcOffset = + src.offset + static_cast<uint64_t>(z) * src.rowsPerImage * src.bytesPerRow; const uint32_t shaderReadOffset = uint32_t(srcOffset); wgpu::Buffer paramsBuffer; {
diff --git a/src/dawn/tests/DawnTest.cpp b/src/dawn/tests/DawnTest.cpp index 772ccf4..679d025 100644 --- a/src/dawn/tests/DawnTest.cpp +++ b/src/dawn/tests/DawnTest.cpp
@@ -1964,7 +1964,8 @@ // Create and initialize the slot buffer so that it won't unexpectedly affect the count of // resources lazily cleared. - const std::vector<float> initialBufferData(width * height * componentCount * sampleCount, 0.f); + const std::vector<float> initialBufferData( + static_cast<size_t>(width) * height * componentCount * sampleCount, 0.f); wgpu::Buffer readbackBuffer = utils::CreateBufferFromData( device, initialBufferData.data(), sizeof(float) * initialBufferData.size(), wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::Storage); @@ -2159,7 +2160,7 @@ wgpu::CommandBuffer commands = commandEncoder.Finish(); queue.Submit(1, &commands); - std::vector<uint32_t> colorData(width * height, 1u); + std::vector<uint32_t> colorData(static_cast<size_t>(width) * height, 1u); return EXPECT_TEXTURE_EQ(colorData.data(), colorTexture, {0, 0}, {width, height}); }
diff --git a/src/dawn/tests/end2end/BindGroupTests.cpp b/src/dawn/tests/end2end/BindGroupTests.cpp index a77b735..f6a089b 100644 --- a/src/dawn/tests/end2end/BindGroupTests.cpp +++ b/src/dawn/tests/end2end/BindGroupTests.cpp
@@ -1395,7 +1395,7 @@ // Create three buffers large enough to by offset by the largest offset. wgpu::BufferDescriptor bufferDescriptor; - bufferDescriptor.size = 3 * mMinUniformBufferOffsetAlignment + sizeof(uint32_t); + bufferDescriptor.size = 3ULL * mMinUniformBufferOffsetAlignment + sizeof(uint32_t); bufferDescriptor.usage = wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopyDst; wgpu::Buffer buffer0 = device.CreateBuffer(&bufferDescriptor); @@ -1477,7 +1477,7 @@ // Create three buffers large enough to by offset by the largest offset. wgpu::BufferDescriptor bufferDescriptor; - bufferDescriptor.size = 2 * mMinUniformBufferOffsetAlignment + sizeof(uint32_t); + bufferDescriptor.size = 2ULL * mMinUniformBufferOffsetAlignment + sizeof(uint32_t); bufferDescriptor.usage = wgpu::BufferUsage::Uniform | wgpu::BufferUsage::CopyDst; wgpu::Buffer dynamicBuffer = device.CreateBuffer(&bufferDescriptor);
diff --git a/src/dawn/tests/end2end/BufferHostMappedPointerTests.cpp b/src/dawn/tests/end2end/BufferHostMappedPointerTests.cpp index 1a2ce80..2f4d4d1 100644 --- a/src/dawn/tests/end2end/BufferHostMappedPointerTests.cpp +++ b/src/dawn/tests/end2end/BufferHostMappedPointerTests.cpp
@@ -121,7 +121,7 @@ // Valid: multiple of required alignment GetParam().mBackend->CreateHostMappedBuffer(device, wgpu::BufferUsage::CopySrc, - 2 * mRequiredAlignment); + 2 * static_cast<size_t>(mRequiredAlignment)); } // Test creating a buffer with data initially in the host-mapped memory. @@ -299,7 +299,7 @@ } // Create buffers on multiple threads. - utils::RunInParallel(buffers.size(), [&, this](uint32_t i) { + utils::RunInParallel(buffers.size(), [&, this](size_t i) { auto [buffer, _] = GetParam().mBackend->CreateHostMappedBuffer( device, wgpu::BufferUsage::CopySrc, bufferSize, [&](void* initialPtr) { DAWN_UNSAFE_TODO(memcpy(initialPtr, &expected[i * u32PerBuffer], bufferSize)); @@ -308,7 +308,7 @@ }); // Check the buffer contents. - for (uint32_t i = 0; i < buffers.size(); ++i) { + for (size_t i = 0; i < buffers.size(); ++i) { EXPECT_BUFFER_U32_RANGE_EQ(&expected[i * u32PerBuffer], buffers[i], 0, u32PerBuffer); } }
diff --git a/src/dawn/tests/end2end/BufferTests.cpp b/src/dawn/tests/end2end/BufferTests.cpp index 0baf485..471d91c 100644 --- a/src/dawn/tests/end2end/BufferTests.cpp +++ b/src/dawn/tests/end2end/BufferTests.cpp
@@ -986,7 +986,7 @@ // Test mappedAtCreation for a large MapWrite buffer TEST_P(BufferMappedAtCreationTests, MapWriteUsageLarge) { - constexpr uint64_t kDataSize = 1000 * 1000; + constexpr uint64_t kDataSize = 1000ULL * 1000; std::vector<uint32_t> myData; for (uint32_t i = 0; i < kDataSize; ++i) { myData.push_back(i); @@ -1004,7 +1004,7 @@ // TODO(crbug.com/473894293): [Capture] buffer mapping: investigate. DAWN_SUPPRESS_TEST_IF(IsCaptureReplayCheckingEnabled()); - constexpr uint64_t kDataSize = 1000 * 1000; + constexpr uint64_t kDataSize = 1000ULL * 1000; std::vector<uint32_t> myData; for (uint32_t i = 0; i < kDataSize; ++i) { myData.push_back(i); @@ -1021,7 +1021,7 @@ // Test mappedAtCreation for a large non-mappable buffer TEST_P(BufferMappedAtCreationTests, NonMappableUsageLarge) { - constexpr uint64_t kDataSize = 1000 * 1000; + constexpr uint64_t kDataSize = 1000ULL * 1000; std::vector<uint32_t> myData; for (uint32_t i = 0; i < kDataSize; ++i) { myData.push_back(i);
diff --git a/src/dawn/tests/end2end/BufferZeroInitTests.cpp b/src/dawn/tests/end2end/BufferZeroInitTests.cpp index c172099..9a26777 100644 --- a/src/dawn/tests/end2end/BufferZeroInitTests.cpp +++ b/src/dawn/tests/end2end/BufferZeroInitTests.cpp
@@ -159,10 +159,11 @@ for (uint32_t slice = 0; slice < spec.textureSize.depthOrArrayLayers; ++slice) { const uint64_t baseOffsetBytesPerSlice = - spec.bufferOffset + spec.bytesPerRow * spec.rowsPerImage * slice; + spec.bufferOffset + + static_cast<uint64_t>(spec.bytesPerRow) * spec.rowsPerImage * slice; for (uint32_t y = 0; y < spec.textureSize.height; ++y) { const uint64_t baseOffsetBytesPerRow = - baseOffsetBytesPerSlice + spec.bytesPerRow * y; + baseOffsetBytesPerSlice + static_cast<uint64_t>(spec.bytesPerRow) * y; const uint64_t baseOffsetFloatCountPerRow = baseOffsetBytesPerRow / sizeof(float); for (uint32_t x = 0; x < spec.textureSize.width; ++x) { expectedValues[baseOffsetFloatCountPerRow + x] = 0.5f; @@ -949,7 +950,7 @@ // bytesPerRow > texelBlockSizeInBytes * copySize.width { - constexpr uint64_t kBytesPerRow = kTextureBytesPerRowAlignment * 2; + constexpr uint64_t kBytesPerRow = kTextureBytesPerRowAlignment * 2ULL; TestBufferZeroInitInCopyTextureToBuffer( {kTextureSize, 0u, 0u, kBytesPerRow, kTextureSize.height, 1u}); }
diff --git a/src/dawn/tests/end2end/ColorStateTests.cpp b/src/dawn/tests/end2end/ColorStateTests.cpp index 1364503..a5124c7 100644 --- a/src/dawn/tests/end2end/ColorStateTests.cpp +++ b/src/dawn/tests/end2end/ColorStateTests.cpp
@@ -1069,7 +1069,7 @@ testPipeline = device.CreateRenderPipeline(&testDescriptor); - for (unsigned int c = 0; c < kColors.size(); ++c) { + for (size_t c = 0; c < kColors.size(); ++c) { utils::RGBA8 base = kColors[((c + 31) * 29) % kColors.size()]; utils::RGBA8 color0 = kColors[((c + 19) * 13) % kColors.size()]; utils::RGBA8 color1 = kColors[((c + 11) * 43) % kColors.size()];
diff --git a/src/dawn/tests/end2end/CompressedTextureFormatTests.cpp b/src/dawn/tests/end2end/CompressedTextureFormatTests.cpp index 9dc48a6..e0af8b1 100644 --- a/src/dawn/tests/end2end/CompressedTextureFormatTests.cpp +++ b/src/dawn/tests/end2end/CompressedTextureFormatTests.cpp
@@ -655,12 +655,12 @@ utils::RGBA8 rightColorInBlock) { DAWN_ASSERT(testRegion.depthOrArrayLayers == 1); - std::vector<utils::RGBA8> expectedData(testRegion.width * testRegion.height, - leftColorInBlock); + std::vector<utils::RGBA8> expectedData( + static_cast<size_t>(testRegion.width) * testRegion.height, leftColorInBlock); for (uint32_t y = 0; y < testRegion.height; ++y) { for (uint32_t x = 0; x < testRegion.width; ++x) { if (x % BlockWidthInTexels() >= BlockWidthInTexels() / 2) { - expectedData[testRegion.width * y + x] = rightColorInBlock; + expectedData[static_cast<size_t>(testRegion.width) * y + x] = rightColorInBlock; } } }
diff --git a/src/dawn/tests/end2end/CopyTests.cpp b/src/dawn/tests/end2end/CopyTests.cpp index ca02717..2996666 100644 --- a/src/dawn/tests/end2end/CopyTests.cpp +++ b/src/dawn/tests/end2end/CopyTests.cpp
@@ -367,9 +367,11 @@ uint32_t srcDepthOffset = z * srcBytesPerRow * srcRowsPerImage; uint32_t dstDepthOffset = z * dstBytesPerRow * dstRowsPerImage; for (unsigned int y = 0; y < heightInBlocks; ++y) { - memcpy(static_cast<uint8_t*>(dstData) + dstDepthOffset + y * dstBytesPerRow, - static_cast<const uint8_t*>(srcData) + srcDepthOffset + y * srcBytesPerRow, - widthInBlocks * bytesPerTexelBlock); + memcpy(static_cast<uint8_t*>(dstData) + dstDepthOffset + + static_cast<size_t>(y) * dstBytesPerRow, + static_cast<const uint8_t*>(srcData) + srcDepthOffset + + static_cast<size_t>(y) * srcBytesPerRow, + static_cast<size_t>(widthInBlocks) * bytesPerTexelBlock); } } } @@ -638,7 +640,7 @@ << errorMsgSs.str(); } - bufferOffset += bufferSpec.bytesPerRow * bufferSpec.rowsPerImage; + bufferOffset += static_cast<uint64_t>(bufferSpec.bytesPerRow) * bufferSpec.rowsPerImage; } if (useMappableBuffer) { @@ -968,7 +970,7 @@ // slice)-th layer to its expected data after the copy (the outputBuffer contains // the data of the destination texture since the dstSpec.copyOrigin.z-th layer). uint64_t outputBufferExpectationBytesOffset = - dstDataCopyLayout.bytesPerImage * slice; + static_cast<uint64_t>(dstDataCopyLayout.bytesPerImage) * slice; EXPECT_BUFFER_U32_RANGE_EQ( reinterpret_cast<const uint32_t*>(expectedDstDataPerSlice.data()), outputBuffer, outputBufferExpectationBytesOffset, @@ -1374,7 +1376,7 @@ for (unsigned int i = 0; i < 3; ++i) { BufferSpec bufferSpec = MinimumBufferSpec(kWidth, kHeight); - uint64_t offset = 512 * i; + uint64_t offset = 512ULL * i; bufferSpec.size += offset; bufferSpec.offset += offset; DoTest(textureSpec, bufferSpec, {kWidth, kHeight, 1}); @@ -1583,7 +1585,7 @@ BufferSpec bufferSpec = MinimumBufferSpec(kWidth, kHeight); for (unsigned int i = 1; i < 4; ++i) { bufferSpec.bytesPerRow += 256; - bufferSpec.size += 256 * kHeight; + bufferSpec.size += 256ULL * kHeight; DoTest(textureSpec, bufferSpec, {kWidth, kHeight, 1}); } } @@ -1602,7 +1604,7 @@ BufferSpec bufferSpec = MinimumBufferSpec(kWidth, kHeight); for (unsigned int i = 1; i < 4; ++i) { bufferSpec.bytesPerRow += 256; - bufferSpec.size += 256 * kHeight; + bufferSpec.size += 256ULL * kHeight; DoTest(textureSpec, bufferSpec, {kWidth, kHeight, 1}); } } @@ -2597,7 +2599,7 @@ for (unsigned int i = 0; i < 3; ++i) { BufferSpec bufferSpec = MinimumBufferSpec(kWidth, kHeight); - uint64_t offset = 512 * i; + uint64_t offset = 512ULL * i; bufferSpec.size += offset; bufferSpec.offset += offset; DoTest(textureSpec, bufferSpec, {kWidth, kHeight, 1}); @@ -2666,7 +2668,7 @@ BufferSpec bufferSpec = MinimumBufferSpec(kWidth, kHeight); for (unsigned int i = 1; i < 4; ++i) { bufferSpec.bytesPerRow += 256; - bufferSpec.size += 256 * kHeight; + bufferSpec.size += 256ULL * kHeight; DoTest(textureSpec, bufferSpec, {kWidth, kHeight, 1}); } } @@ -2685,7 +2687,7 @@ BufferSpec bufferSpec = MinimumBufferSpec(kWidth, kHeight); for (unsigned int i = 1; i < 4; ++i) { bufferSpec.bytesPerRow += 256; - bufferSpec.size += 256 * kHeight; + bufferSpec.size += 256ULL * kHeight; DoTest(textureSpec, bufferSpec, {kWidth, kHeight, 1}); } } @@ -4201,7 +4203,7 @@ // Dirty the GPU heap with a recognizable pattern. // Use a large enough size to likely hit the same heap as the upcoming temporary buffer. { - constexpr uint64_t kDirtySize = 64 * 1024; + constexpr uint64_t kDirtySize = 64ULL * 1024; constexpr uint32_t kPattern = 0xDEADBEEF; wgpu::BufferDescriptor descriptor;
diff --git a/src/dawn/tests/end2end/DepthStencilCopyTests.cpp b/src/dawn/tests/end2end/DepthStencilCopyTests.cpp index 90a282c..e5c7fe0 100644 --- a/src/dawn/tests/end2end/DepthStencilCopyTests.cpp +++ b/src/dawn/tests/end2end/DepthStencilCopyTests.cpp
@@ -595,9 +595,10 @@ if (format == wgpu::TextureFormat::Depth16Unorm) { uint16_t expected = FloatToUnorm<uint16_t>(kInitDepth); uint16_t cleared = FloatToUnorm<uint16_t>(kClearDepth); - std::vector<uint16_t> expectedData(copyWidth * copyHeight, cleared); + std::vector<uint16_t> expectedData(static_cast<size_t>(copyWidth) * copyHeight, + cleared); for (uint32_t y = copyHeight / 2; y < copyHeight; y++) { - auto rowStart = expectedData.data() + y * copyWidth; + auto rowStart = expectedData.data() + static_cast<size_t>(y) * copyWidth; std::fill(rowStart, rowStart + copyWidth / 2, expected); } @@ -605,7 +606,8 @@ uint32_t bufferOffsetPerArrayLayer = bytesPerImage * z; for (uint32_t y = 0; y < copyHeight; ++y) { EXPECT_BUFFER_U16_RANGE_EQ( - expectedData.data() + copyWidth * y, destinationBuffer, + expectedData.data() + static_cast<size_t>(copyWidth) * y, + destinationBuffer, bufferCopyOffset + bufferOffsetPerArrayLayer + y * bytesPerRow, copyWidth); } @@ -615,9 +617,10 @@ format == wgpu::TextureFormat::Depth24PlusStencil8) ? 3e-8f : 0.0f; - std::vector<float> expectedData(copyWidth * copyHeight, kClearDepth); + std::vector<float> expectedData(static_cast<size_t>(copyWidth) * copyHeight, + kClearDepth); for (uint32_t y = copyHeight / 2; y < copyHeight; y++) { - auto rowStart = expectedData.data() + y * copyWidth; + auto rowStart = expectedData.data() + static_cast<size_t>(y) * copyWidth; std::fill(rowStart, rowStart + copyWidth / 2, kInitDepth); } @@ -625,7 +628,8 @@ uint32_t bufferOffsetPerArrayLayer = bytesPerImage * z; for (uint32_t y = 0; y < copyHeight; ++y) { EXPECT_BUFFER_FLOAT_RANGE_TOLERANCE_EQ( - expectedData.data() + copyWidth * y, destinationBuffer, + expectedData.data() + static_cast<size_t>(copyWidth) * y, + destinationBuffer, bufferCopyOffset + bufferOffsetPerArrayLayer + y * bytesPerRow, copyWidth, tolerance); } @@ -1058,10 +1062,11 @@ queue.Submit(1, &commandBuffer); if (checkBufferContent) { - std::vector<uint8_t> expectedData(copyWidth * copyHeight, kClearStencil); + std::vector<uint8_t> expectedData(static_cast<size_t>(copyWidth) * copyHeight, + kClearStencil); // std::fill(expectedData.data(), expectedData.data() + expectedData.size(), 0x77); for (uint32_t y = copyHeight / 2; y < copyHeight; y++) { - auto rowStart = expectedData.data() + y * copyWidth; + auto rowStart = expectedData.data() + static_cast<size_t>(y) * copyWidth; std::fill(rowStart, rowStart + copyWidth / 2, kInitStencil); } @@ -1069,7 +1074,7 @@ uint32_t bufferOffsetPerArrayLayer = bytesPerImage * z; for (uint32_t y = 0; y < copyHeight; ++y) { EXPECT_BUFFER_U8_RANGE_EQ( - expectedData.data() + copyWidth * y, destinationBuffer, + expectedData.data() + static_cast<size_t>(copyWidth) * y, destinationBuffer, bufferCopyOffset + bufferOffsetPerArrayLayer + y * bytesPerRow, copyWidth); } } @@ -1130,7 +1135,8 @@ uint8_t* mappedPtr = static_cast<uint8_t*>(srcBuffer.GetMappedRange(bufferCopyOffset)); constexpr uint32_t kBytesPerRow = kTextureBytesPerRowAlignment; for (uint32_t y = 0; y < kHeight; ++y) { - memcpy(mappedPtr + y * kBytesPerRow, stencilData.data() + y * kWidth, kWidth); + memcpy(mappedPtr + static_cast<size_t>(y) * kBytesPerRow, + stencilData.data() + static_cast<size_t>(y) * kWidth, kWidth); } srcBuffer.Unmap();
diff --git a/src/dawn/tests/end2end/DepthStencilLoadOpTests.cpp b/src/dawn/tests/end2end/DepthStencilLoadOpTests.cpp index 3cdabd9..767dfa3 100644 --- a/src/dawn/tests/end2end/DepthStencilLoadOpTests.cpp +++ b/src/dawn/tests/end2end/DepthStencilLoadOpTests.cpp
@@ -132,7 +132,8 @@ // textureLoad with texture_depth_xxx is not supported in compat mode. DAWN_TEST_UNSUPPORTED_IF(IsCompatibilityMode()); - std::vector<float> expectedDepth(mipSize * mipSize, kDepthValues[mipLevel]); + std::vector<float> expectedDepth(static_cast<size_t>(mipSize) * mipSize, + kDepthValues[mipLevel]); ExpectSampledDepthData( texture, mipSize, mipSize, 0, mipLevel, new detail::ExpectEq<float>(expectedDepth.data(), expectedDepth.size(), 0.0001)) @@ -144,14 +145,15 @@ DAWN_TEST_UNSUPPORTED_IF(utils::IsStencilOnlyFormat(GetParam().mFormat)); if (GetParam().mFormat == wgpu::TextureFormat::Depth16Unorm) { - std::vector<uint16_t> expectedDepth(mipSize * mipSize, + std::vector<uint16_t> expectedDepth(static_cast<size_t>(mipSize) * mipSize, kU16DepthValues[mipLevel]); EXPECT_TEXTURE_EQ(expectedDepth.data(), texture, {0, 0}, {mipSize, mipSize}, mipLevel, wgpu::TextureAspect::DepthOnly, /* bytesPerRow */ 0, /* tolerance */ uint16_t(1)) << "copy depth mip " << mipLevel; } else { - std::vector<float> expectedDepth(mipSize * mipSize, kDepthValues[mipLevel]); + std::vector<float> expectedDepth(static_cast<size_t>(mipSize) * mipSize, + kDepthValues[mipLevel]); EXPECT_TEXTURE_EQ(expectedDepth.data(), texture, {0, 0}, {mipSize, mipSize}, mipLevel, wgpu::TextureAspect::DepthOnly) << "copy depth mip " << mipLevel; @@ -161,7 +163,8 @@ } case Check::CopyStencil: { - std::vector<uint8_t> expectedStencil(mipSize * mipSize, kStencilValues[mipLevel]); + std::vector<uint8_t> expectedStencil(static_cast<size_t>(mipSize) * mipSize, + kStencilValues[mipLevel]); EXPECT_TEXTURE_EQ(expectedStencil.data(), texture, {0, 0}, {mipSize, mipSize}, mipLevel, wgpu::TextureAspect::StencilOnly) << "copy stencil mip " << mipLevel; @@ -171,7 +174,8 @@ case Check::DepthTest: { DAWN_TEST_UNSUPPORTED_IF(utils::IsStencilOnlyFormat(GetParam().mFormat)); - std::vector<float> expectedDepth(mipSize * mipSize, kDepthValues[mipLevel]); + std::vector<float> expectedDepth(static_cast<size_t>(mipSize) * mipSize, + kDepthValues[mipLevel]); ExpectAttachmentDepthTestData(texture, GetParam().mFormat, mipSize, mipSize, 0, mipLevel, expectedDepth) << "depth test mip " << mipLevel; @@ -466,7 +470,7 @@ constexpr std::array<uint32_t, 3> kLevelsToTest = {0, 1u, 3u}; for (uint32_t level : kLevelsToTest) { uint32_t sizeAtLevel = kSize >> level; - std::vector<float> expectedValue(sizeAtLevel * sizeAtLevel, 0.f); + std::vector<float> expectedValue(static_cast<size_t>(sizeAtLevel) * sizeAtLevel, 0.f); ExpectAttachmentDepthTestData(depthTexture, GetParam().mFormat, sizeAtLevel, sizeAtLevel, 0, level, expectedValue); }
diff --git a/src/dawn/tests/end2end/DynamicBufferOffsetTests.cpp b/src/dawn/tests/end2end/DynamicBufferOffsetTests.cpp index 05c2e13..45e802c 100644 --- a/src/dawn/tests/end2end/DynamicBufferOffsetTests.cpp +++ b/src/dawn/tests/end2end/DynamicBufferOffsetTests.cpp
@@ -674,7 +674,8 @@ uint32_t minUniformBufferOffsetAlignment = GetSupportedLimits().minUniformBufferOffsetAlignment; uint32_t minStorageBufferOffsetAlignment = GetSupportedLimits().minStorageBufferOffsetAlignment; - uint32_t arrayByteLength = kArrayLength * 4 * sizeof(uint32_t); + uint32_t arrayByteLength = + static_cast<uint32_t>(static_cast<size_t>(kArrayLength) * 4 * sizeof(uint32_t)); uint32_t uniformBufferOffset = Align(arrayByteLength, minUniformBufferOffsetAlignment); uint32_t storageBufferOffset = Align(arrayByteLength, minStorageBufferOffsetAlignment);
diff --git a/src/dawn/tests/end2end/FirstIndexOffsetTests.cpp b/src/dawn/tests/end2end/FirstIndexOffsetTests.cpp index f18b25e..8d85cfd 100644 --- a/src/dawn/tests/end2end/FirstIndexOffsetTests.cpp +++ b/src/dawn/tests/end2end/FirstIndexOffsetTests.cpp
@@ -87,7 +87,8 @@ private: wgpu::Buffer CreateVertexBuffer(uint32_t firstVertexOffset) { - std::vector<float> vertexData(firstVertexOffset * kComponentsPerVertex); + std::vector<float> vertexData(static_cast<size_t>(firstVertexOffset) * + kComponentsPerVertex); vertexData.insert(vertexData.end(), {0, 0, 0, 1}); vertexData.insert(vertexData.end(), {0, 0, 0, 1}); return utils::CreateBufferFromData(device, vertexData.data(),
diff --git a/src/dawn/tests/end2end/GpuMemorySynchronizationTests.cpp b/src/dawn/tests/end2end/GpuMemorySynchronizationTests.cpp index 061c12d..a104ae7 100644 --- a/src/dawn/tests/end2end/GpuMemorySynchronizationTests.cpp +++ b/src/dawn/tests/end2end/GpuMemorySynchronizationTests.cpp
@@ -499,7 +499,7 @@ cpDesc.compute.module = csModule; wgpu::ComputePipeline cp = device.CreateComputePipeline(&cpDesc); wgpu::Buffer vertexBuffer = CreateZeroedBuffer( - kVertexBufferStride * 4, + kVertexBufferStride * 4ULL, wgpu::BufferUsage::Vertex | wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopyDst); wgpu::Buffer indexBuffer = CreateZeroedBuffer( sizeof(int) * 4 * 2,
diff --git a/src/dawn/tests/end2end/ImmediateDataBufferLengthTests.cpp b/src/dawn/tests/end2end/ImmediateDataBufferLengthTests.cpp index 8e5f950..2837652 100644 --- a/src/dawn/tests/end2end/ImmediateDataBufferLengthTests.cpp +++ b/src/dawn/tests/end2end/ImmediateDataBufferLengthTests.cpp
@@ -261,11 +261,10 @@ resultIndex++; } - static constexpr uint32_t kMaxExecutionTime = 2u; - static constexpr uint32_t kMaxImmediateCount = 4u; - static constexpr uint32_t kMaxStorageBufferCount = 3u; - static constexpr uint32_t kResultSizeInExpectation = - kMaxImmediateCount + kMaxStorageBufferCount; + static constexpr size_t kMaxExecutionTime = 2u; + static constexpr size_t kMaxImmediateCount = 4u; + static constexpr size_t kMaxStorageBufferCount = 3u; + static constexpr size_t kResultSizeInExpectation = kMaxImmediateCount + kMaxStorageBufferCount; std::vector<wgpu::Buffer> mStorageBuffers; wgpu::Buffer mResultBuffer;
diff --git a/src/dawn/tests/end2end/MaxLimitTests.cpp b/src/dawn/tests/end2end/MaxLimitTests.cpp index b9d1e7d..875b6d3 100644 --- a/src/dawn/tests/end2end/MaxLimitTests.cpp +++ b/src/dawn/tests/end2end/MaxLimitTests.cpp
@@ -190,7 +190,7 @@ uint64_t(std::numeric_limits<int32_t>::max()) + 8); maxBufferBindingSize = Align(maxBufferBindingSize - 3u, 4); - const uint64_t kMaxStructMemberU32ArraySize = 65535 * 4; + const uint64_t kMaxStructMemberU32ArraySize = 65535ULL * 4; uint64_t paddingNeeded = maxBufferBindingSize - 8; uint64_t numPaddingMembers = (paddingNeeded + kMaxStructMemberU32ArraySize - 1) / kMaxStructMemberU32ArraySize;
diff --git a/src/dawn/tests/end2end/MemoryAllocationStressTests.cpp b/src/dawn/tests/end2end/MemoryAllocationStressTests.cpp index 1c0e920..80f06fb 100644 --- a/src/dawn/tests/end2end/MemoryAllocationStressTests.cpp +++ b/src/dawn/tests/end2end/MemoryAllocationStressTests.cpp
@@ -46,7 +46,7 @@ uint32_t count = 100; for (uint32_t i = 0; i < count; i++) { wgpu::BufferDescriptor descriptor; - descriptor.size = 1024 * 1024 * 1024; // 1G + descriptor.size = 1024ULL * 1024 * 1024; // 1G descriptor.usage = wgpu::BufferUsage::Storage; wgpu::Buffer buffer = device.CreateBuffer(&descriptor); buffer.Destroy();
diff --git a/src/dawn/tests/end2end/MultisampledRenderingTests.cpp b/src/dawn/tests/end2end/MultisampledRenderingTests.cpp index 1e4874b..9d7a5d3 100644 --- a/src/dawn/tests/end2end/MultisampledRenderingTests.cpp +++ b/src/dawn/tests/end2end/MultisampledRenderingTests.cpp
@@ -1980,7 +1980,7 @@ const wgpu::Texture& msaaTexture) { auto textureWidth = msaaTexture.GetWidth(); auto textureHeight = msaaTexture.GetHeight(); - std::vector<Point> points(textureWidth * textureHeight); + std::vector<Point> points(static_cast<size_t>(textureWidth) * textureHeight); for (size_t i = 0; i < points.size(); ++i) { uint32_t x = i % (textureWidth); uint32_t y = i / (textureWidth); @@ -2918,7 +2918,7 @@ wgpu::TexelCopyTextureInfo dst = {}; dst.texture = mResolveTexture; - std::array<utils::RGBA8, resolveWidth * resolveHeight> rgbaTextureData; + std::array<utils::RGBA8, static_cast<size_t>(resolveWidth) * resolveHeight> rgbaTextureData; for (size_t i = 0; i < rgbaTextureData.size(); ++i) { rgbaTextureData[i] = utils::RGBA8(0, 0, 0, 255); }
diff --git a/src/dawn/tests/end2end/MultisampledSamplingTests.cpp b/src/dawn/tests/end2end/MultisampledSamplingTests.cpp index f59db51..1d0812a 100644 --- a/src/dawn/tests/end2end/MultisampledSamplingTests.cpp +++ b/src/dawn/tests/end2end/MultisampledSamplingTests.cpp
@@ -222,8 +222,8 @@ wgpu::RenderPassEncoder renderPassEncoder = commandEncoder.BeginRenderPass(&renderPass); renderPassEncoder.SetPipeline(drawPipeline); - renderPassEncoder.SetVertexBuffer(0, vBuffer, kQuadNumBytes * sampleOffset, - kQuadNumBytes); + renderPassEncoder.SetVertexBuffer( + 0, vBuffer, static_cast<uint64_t>(kQuadNumBytes) * sampleOffset, kQuadNumBytes); renderPassEncoder.Draw(4); renderPassEncoder.End();
diff --git a/src/dawn/tests/end2end/MultithreadTests.cpp b/src/dawn/tests/end2end/MultithreadTests.cpp index 63b7924..159dc65 100644 --- a/src/dawn/tests/end2end/MultithreadTests.cpp +++ b/src/dawn/tests/end2end/MultithreadTests.cpp
@@ -628,9 +628,10 @@ constexpr uint32_t kTextureSize = 512; constexpr wgpu::TextureFormat kTextureFormat = wgpu::TextureFormat::RGBA8Unorm; constexpr uint32_t kBytesPerPixel = 4; - constexpr uint64_t kBufferSize = kTextureSize * kTextureSize * kBytesPerPixel; + constexpr uint64_t kBufferSize = + static_cast<uint64_t>(kTextureSize) * kTextureSize * kBytesPerPixel; - std::vector<utils::RGBA8> textureData(kTextureSize * kTextureSize); + std::vector<utils::RGBA8> textureData(static_cast<size_t>(kTextureSize) * kTextureSize); for (uint32_t y = 0; y < kTextureSize; ++y) { for (uint32_t x = 0; x < kTextureSize; ++x) { textureData[y * kTextureSize + x] =
diff --git a/src/dawn/tests/end2end/PackUnpack4x8NormTests.cpp b/src/dawn/tests/end2end/PackUnpack4x8NormTests.cpp index 1a921f1..3de84ef 100644 --- a/src/dawn/tests/end2end/PackUnpack4x8NormTests.cpp +++ b/src/dawn/tests/end2end/PackUnpack4x8NormTests.cpp
@@ -177,7 +177,7 @@ static uint32_t kNumTests = 7; wgpu::BufferDescriptor bufferDesc; - bufferDesc.size = kNumTests * 4 * sizeof(float); + bufferDesc.size = static_cast<uint64_t>(kNumTests) * 4 * sizeof(float); bufferDesc.usage = wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopySrc; wgpu::Buffer bufferOut = device.CreateBuffer(&bufferDesc); @@ -247,7 +247,7 @@ static uint32_t kNumTests = 8; wgpu::BufferDescriptor bufferDesc; - bufferDesc.size = kNumTests * 4 * sizeof(float); + bufferDesc.size = static_cast<uint64_t>(kNumTests) * 4 * sizeof(float); bufferDesc.usage = wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopySrc; wgpu::Buffer bufferOut = device.CreateBuffer(&bufferDesc);
diff --git a/src/dawn/tests/end2end/QueueTests.cpp b/src/dawn/tests/end2end/QueueTests.cpp index 1073a56..e09c8f8 100644 --- a/src/dawn/tests/end2end/QueueTests.cpp +++ b/src/dawn/tests/end2end/QueueTests.cpp
@@ -140,7 +140,7 @@ // this test to take forever. Skip it when VVLs are enabled. DAWN_SUPPRESS_TEST_IF(IsVulkan() && IsBackendValidationEnabled()); - constexpr uint64_t kSize = 4000 * 1000; + constexpr uint64_t kSize = 4000ULL * 1000; constexpr uint32_t kElements = 250 * 250; wgpu::BufferDescriptor descriptor; descriptor.size = kSize; @@ -158,7 +158,7 @@ // Test using WriteBuffer for lots of data TEST_P(QueueWriteBufferTests, LargeWriteBuffer) { - constexpr uint64_t kSize = 4000 * 1000; + constexpr uint64_t kSize = 4000ULL * 1000; constexpr uint32_t kElements = 1000 * 1000; wgpu::BufferDescriptor descriptor; descriptor.size = kSize; @@ -177,8 +177,8 @@ // Test using WriteBuffer for super large data block TEST_P(QueueWriteBufferTests, SuperLargeWriteBuffer) { - constexpr uint64_t kSize = 12000 * 1000; - constexpr uint64_t kElements = 3000 * 1000; + constexpr uint64_t kSize = 12000ULL * 1000; + constexpr uint64_t kElements = 3000ULL * 1000; wgpu::BufferDescriptor descriptor; descriptor.size = kSize; descriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst; @@ -823,7 +823,7 @@ constexpr wgpu::TextureFormat kFormat = wgpu::TextureFormat::RGBA8Unorm; constexpr uint32_t kPixelSize = 4; - std::vector<uint32_t> data(width * height); + std::vector<uint32_t> data(static_cast<size_t>(width) * height); for (size_t i = 0; i < data.size(); i++) { data[i] = 0xFFFFFFFF; } @@ -840,8 +840,8 @@ utils::CreateTexelCopyBufferLayout(0, width * kPixelSize); wgpu::Extent3D copyExtent = {width, height, 1}; device.GetQueue().WriteTexture(&texelCopyTextureInfo, data.data(), - width * height * kPixelSize, &texelCopyBufferLayout, - ©Extent); + static_cast<size_t>(width) * height * kPixelSize, + &texelCopyBufferLayout, ©Extent); EXPECT_TEXTURE_EQ(data.data(), texture, {0, 0}, {width, height}); }
diff --git a/src/dawn/tests/end2end/ReadOnlyDepthStencilAttachmentTests.cpp b/src/dawn/tests/end2end/ReadOnlyDepthStencilAttachmentTests.cpp index bff7ba0..7e4ebae 100644 --- a/src/dawn/tests/end2end/ReadOnlyDepthStencilAttachmentTests.cpp +++ b/src/dawn/tests/end2end/ReadOnlyDepthStencilAttachmentTests.cpp
@@ -36,7 +36,7 @@ namespace dawn { namespace { -constexpr static uint32_t kSize = 4; +constexpr size_t kSize = 4; using TextureFormat = wgpu::TextureFormat; DAWN_TEST_PARAM_STRUCT(ReadOnlyDepthStencilAttachmentTestsParams, TextureFormat); @@ -280,9 +280,9 @@ } void CheckTopBottomColor(wgpu::Texture color, utils::RGBA8 topColor, utils::RGBA8 bottomColor) { - std::vector<utils::RGBA8> expectedTop(kSize * kSize / 2, topColor); + std::vector<utils::RGBA8> expectedTop((kSize * kSize) / 2, topColor); EXPECT_TEXTURE_EQ(expectedTop.data(), color, {0, 0}, {kSize, kSize / 2}); - std::vector<utils::RGBA8> expectedBottom(kSize * kSize / 2, bottomColor); + std::vector<utils::RGBA8> expectedBottom((kSize * kSize) / 2, bottomColor); EXPECT_TEXTURE_EQ(expectedBottom.data(), color, {0, kSize / 2}, {kSize, kSize / 2}); }
diff --git a/src/dawn/tests/end2end/RenderPassLoadOpTests.cpp b/src/dawn/tests/end2end/RenderPassLoadOpTests.cpp index ab8d94b..0014a32 100644 --- a/src/dawn/tests/end2end/RenderPassLoadOpTests.cpp +++ b/src/dawn/tests/end2end/RenderPassLoadOpTests.cpp
@@ -41,7 +41,7 @@ namespace dawn { namespace { -constexpr static unsigned int kRTSize = 16; +constexpr size_t kRTSize = 16; class DrawQuad { public:
diff --git a/src/dawn/tests/end2end/RenderPassTests.cpp b/src/dawn/tests/end2end/RenderPassTests.cpp index 4ff7486..2088f27 100644 --- a/src/dawn/tests/end2end/RenderPassTests.cpp +++ b/src/dawn/tests/end2end/RenderPassTests.cpp
@@ -336,7 +336,8 @@ // Use a distinct value for each subresource. uint16_t value = level * 10 + layer; - std::vector<uint16_t> data(copySize.width * copySize.height, value); + std::vector<uint16_t> data( + static_cast<size_t>(copySize.width) * copySize.height, value); queue.WriteTexture(&texelCopyTextureInfo, data.data(), data.size() * sizeof(uint16_t), &texelCopyBufferLayout, ©Size); @@ -395,7 +396,8 @@ uint32_t mipHeight = height >> level; if (cleared) { // Check the subresource is cleared as expected. - std::vector<uint16_t> data(mipWidth * mipHeight, 0xCCCC); + std::vector<uint16_t> data(static_cast<size_t>(mipWidth) * mipHeight, + 0xCCCC); EXPECT_TEXTURE_EQ(data.data(), tex, {0, 0, layer}, {mipWidth, mipHeight}, level) << "cleared texture data should have been 0xCCCC at:" << "\nlayer: " @@ -405,7 +407,8 @@ // Without the workaround, they are 0. uint16_t value = level * 10 + layer; // Compute the expected value for the subresource. - std::vector<uint16_t> data(mipWidth * mipHeight, value); + std::vector<uint16_t> data(static_cast<size_t>(mipWidth) * mipHeight, + value); EXPECT_TEXTURE_EQ(data.data(), tex, {0, 0, layer}, {mipWidth, mipHeight}, level) << "written texture data should still be " << value
diff --git a/src/dawn/tests/end2end/RequiredBufferSizeInCopyTests.cpp b/src/dawn/tests/end2end/RequiredBufferSizeInCopyTests.cpp index 1b52eba..8552bf5 100644 --- a/src/dawn/tests/end2end/RequiredBufferSizeInCopyTests.cpp +++ b/src/dawn/tests/end2end/RequiredBufferSizeInCopyTests.cpp
@@ -131,7 +131,7 @@ uint64_t imageSize = kBytesPerRow * rowsPerImage; DAWN_ASSERT(bufferSize >= (imageSize * (copySize.depthOrArrayLayers - 1) + kBytesPerBlock)); uint32_t numOfImageElements = imageSize / kBytesPerBlock; - for (uint32_t i = 0; i < copySize.depthOrArrayLayers; ++i) { + for (size_t i = 0; i < copySize.depthOrArrayLayers; ++i) { data[i * numOfImageElements] = 0x80808080; expectedBufferData[i * numOfImageElements] = 0x80808080; expectedTextureData[i] = 0x80808080; @@ -195,7 +195,8 @@ const uint64_t rowsPerImage = extraRowsPerImage + copySize.height; uint64_t size = kOffset + kBytesPerRow * rowsPerImage * (copySize.depthOrArrayLayers - 1) + - kBytesPerRow * (rowsPerImage - 1) + kBytesPerBlock * copySize.width; + kBytesPerRow * (rowsPerImage - 1) + + static_cast<uint64_t>(kBytesPerBlock) * copySize.width; DoTest(size, copySize, rowsPerImage); size -= kBytesPerBlock;
diff --git a/src/dawn/tests/end2end/ResourceTableTests.cpp b/src/dawn/tests/end2end/ResourceTableTests.cpp index 2116329..7397c32 100644 --- a/src/dawn/tests/end2end/ResourceTableTests.cpp +++ b/src/dawn/tests/end2end/ResourceTableTests.cpp
@@ -474,7 +474,7 @@ auto texture = device.CreateTexture(&descriptor); const uint32_t rowPixels = kTextureBytesPerRowAlignment / sizeof(utils::RGBA8); - std::array<utils::RGBA8, rowPixels * 2> pixels; + std::array<utils::RGBA8, static_cast<size_t>(rowPixels) * 2> pixels; pixels[0] = pixels[rowPixels + 1] = utils::RGBA8::kRed; pixels[1] = pixels[rowPixels] = utils::RGBA8::kGreen; @@ -1799,16 +1799,16 @@ float expectedRed[4] = {1.0, 0.0, 0.0, 1.0}; // repeat: 1,0 -> red, 1.5,0 -> green - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedRed, resultBuffer, 0 * 4 * sizeof(float), 4); - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 1 * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedRed, resultBuffer, 0ULL * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 1ULL * 4 * sizeof(float), 4); // mirror: 1,0 -> green, 1.5,0 -> red - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 2 * 4 * sizeof(float), 4); - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedRed, resultBuffer, 3 * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 2ULL * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedRed, resultBuffer, 3ULL * 4 * sizeof(float), 4); // clamp: 1,0 -> green, 1.5,0 -> green - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 4 * 4 * sizeof(float), 4); - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 5 * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 4ULL * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 5ULL * 4 * sizeof(float), 4); } } @@ -1901,17 +1901,17 @@ float expectedGreen[4] = {1.0, 0.0, 0.0, 1.0}; // The default non-filtering sampler should return red at (0.5, 0.5), and green at (0.6, 0.6) - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedRed, resultBuffer, 0 * 4 * sizeof(float), 4); - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 1 * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedRed, resultBuffer, 0ULL * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 1ULL * 4 * sizeof(float), 4); // The default filtering sampler is actually a non-filtering one, so should return the same - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedRed, resultBuffer, 2 * 4 * sizeof(float), 4); - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 3 * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedRed, resultBuffer, 2ULL * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 3ULL * 4 * sizeof(float), 4); // The comparison sampler is an 'always' one, so it should return 1.0, which the shader returns // in two of the vector elements. float expectedCompare[4] = {1.0, 42.0, 1.0, 83.5}; - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedCompare, resultBuffer, 4 * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedCompare, resultBuffer, 4ULL * 4 * sizeof(float), 4); } // Test that removing then adding a new sampler in a slot that already has a sampler of the same @@ -1995,8 +1995,8 @@ draw(); // repeat: 1,0 -> red, 1.5,0 -> green - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedRed, resultBuffer, 0 * 4 * sizeof(float), 4); - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 1 * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedRed, resultBuffer, 0ULL * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 1ULL * 4 * sizeof(float), 4); // Now test removing then adding mirror sampler EXPECT_EQ(wgpu::Status::Success, table.RemoveBinding(1)); @@ -2006,8 +2006,8 @@ draw(); // mirror: 1,0 -> green, 1.5,0 -> red - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 0 * 4 * sizeof(float), 4); - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedRed, resultBuffer, 1 * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 0ULL * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedRed, resultBuffer, 1ULL * 4 * sizeof(float), 4); } // Test that adding and removing samplers in the same slot between draws ensure that @@ -2093,8 +2093,8 @@ draw(); // repeat: 1,0 -> red, 1.5,0 -> green - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedRed, resultBuffer, 0 * 4 * sizeof(float), 4); - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 1 * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedRed, resultBuffer, 0ULL * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 1ULL * 4 * sizeof(float), 4); // Remove then add mirror samplers for (auto sampler : samplerMirror) { @@ -2114,8 +2114,8 @@ draw(); // clamp: 1,0 -> green, 1.5,0 -> green - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 0 * 4 * sizeof(float), 4); - EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 1 * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 0ULL * 4 * sizeof(float), 4); + EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedGreen, resultBuffer, 1ULL * 4 * sizeof(float), 4); } // Test what happens when we add more than kD3D12MaxUniqueSamplers unique samplers
diff --git a/src/dawn/tests/end2end/SamplerFilterAnisotropicTests.cpp b/src/dawn/tests/end2end/SamplerFilterAnisotropicTests.cpp index 0e0b01e..f4538dd 100644 --- a/src/dawn/tests/end2end/SamplerFilterAnisotropicTests.cpp +++ b/src/dawn/tests/end2end/SamplerFilterAnisotropicTests.cpp
@@ -137,7 +137,7 @@ const utils::RGBA8 color = colors[level]; - std::vector<utils::RGBA8> data(rowPixels * texHeight, color); + std::vector<utils::RGBA8> data(static_cast<size_t>(rowPixels) * texHeight, color); wgpu::Buffer stagingBuffer = utils::CreateBufferFromData(device, data.data(), data.size() * sizeof(utils::RGBA8), wgpu::BufferUsage::CopySrc);
diff --git a/src/dawn/tests/end2end/SamplerTests.cpp b/src/dawn/tests/end2end/SamplerTests.cpp index d3e54c7..743a0b7 100644 --- a/src/dawn/tests/end2end/SamplerTests.cpp +++ b/src/dawn/tests/end2end/SamplerTests.cpp
@@ -107,7 +107,7 @@ // Create a 2x2 checkerboard texture, with black in the top left and bottom right corners. const uint32_t rowPixels = kTextureBytesPerRowAlignment / sizeof(utils::RGBA8); - std::array<utils::RGBA8, rowPixels * 2> pixels; + std::array<utils::RGBA8, static_cast<size_t>(rowPixels) * 2> pixels; pixels[0] = pixels[rowPixels + 1] = utils::RGBA8::kBlack; pixels[1] = pixels[rowPixels] = utils::RGBA8::kWhite;
diff --git a/src/dawn/tests/end2end/ShaderF16Tests.cpp b/src/dawn/tests/end2end/ShaderF16Tests.cpp index af9bb58..fff24c6 100644 --- a/src/dawn/tests/end2end/ShaderF16Tests.cpp +++ b/src/dawn/tests/end2end/ShaderF16Tests.cpp
@@ -376,10 +376,10 @@ // corresponding WGSL type vec2<f16> and vec4<f16> by driver. // Buffer for pos_half wgpu::Buffer vertexBufferPos = utils::CreateBufferFromData( - device, positionData.data(), 2 * kPointCount * sizeof(float), wgpu::BufferUsage::Vertex); + device, positionData.data(), 2ULL * kPointCount * sizeof(float), wgpu::BufferUsage::Vertex); // Buffer for color_quarter wgpu::Buffer vertexBufferColor = utils::CreateBufferFromData( - device, colorData.data(), 4 * kPointCount * sizeof(float), wgpu::BufferUsage::Vertex); + device, colorData.data(), 4ULL * kPointCount * sizeof(float), wgpu::BufferUsage::Vertex); // Create render pipeline. wgpu::RenderPipeline pipeline;
diff --git a/src/dawn/tests/end2end/StorageTextureTests.cpp b/src/dawn/tests/end2end/StorageTextureTests.cpp index eecd244..8dc40ab 100644 --- a/src/dawn/tests/end2end/StorageTextureTests.cpp +++ b/src/dawn/tests/end2end/StorageTextureTests.cpp
@@ -621,7 +621,7 @@ std::vector<uint8_t> outputData(texelSizeInBytes * kWidth * kHeight * sliceCount); - for (uint32_t i = 0; i < outputData.size() / texelSizeInBytes; ++i) { + for (size_t i = 0; i < outputData.size() / texelSizeInBytes; ++i) { uint8_t* pixelValuePtr = &outputData[i * texelSizeInBytes]; const uint32_t x = i % kWidth; const uint32_t y = (i % (kWidth * kHeight)) / kWidth; @@ -899,7 +899,8 @@ for (size_t y = 0; y < size.height; ++y) { const size_t resultBufferOffset = kTextureBytesPerRowAlignment * (size.height * z + y); - const size_t expectedDataOffset = texelSize * size.width * (size.height * z + y); + const size_t expectedDataOffset = + static_cast<size_t>(texelSize) * size.width * (size.height * z + y); EXPECT_BUFFER_U32_RANGE_EQ( reinterpret_cast<const uint32_t*>(expectedData + expectedDataOffset), resultBuffer, resultBufferOffset, texelSize); @@ -1339,7 +1340,8 @@ const uint32_t texelSizeInBytes = utils::GetTexelBlockSizeInBytes(format); for (uint32_t i = 0; i < kWidth * kHeight; ++i) { - uint8_t* pixelValuePtr = &expectedModifiedData[i * texelSizeInBytes]; + uint8_t* pixelValuePtr = + &expectedModifiedData[static_cast<size_t>(i) * texelSizeInBytes]; const uint32_t x = i % kWidth; const uint32_t y = i / kWidth; FillExpectedData(pixelValuePtr, format, x, y, 0, expectedResultIncrement);
diff --git a/src/dawn/tests/end2end/SubgroupMatrixTests.cpp b/src/dawn/tests/end2end/SubgroupMatrixTests.cpp index 8365965..a75c70e 100644 --- a/src/dawn/tests/end2end/SubgroupMatrixTests.cpp +++ b/src/dawn/tests/end2end/SubgroupMatrixTests.cpp
@@ -580,7 +580,7 @@ // Create the output buffer and copy the accumulator to it. wgpu::BufferDescriptor outputDescriptor{ .usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::Storage, - .size = config.M * config.N * resultComponentByteSize, + .size = static_cast<uint64_t>(config.M) * config.N * resultComponentByteSize, .mappedAtCreation = true, }; wgpu::Buffer output = device.CreateBuffer(&outputDescriptor); @@ -798,7 +798,7 @@ // Create the output buffer wgpu::BufferDescriptor outputDescriptor{ .usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::Storage, - .size = config.K * config.M * componentByteSize, + .size = static_cast<uint64_t>(config.K) * config.M * componentByteSize, .mappedAtCreation = false, }; wgpu::Buffer output = device.CreateBuffer(&outputDescriptor); @@ -1471,7 +1471,7 @@ // Create the output buffer. wgpu::BufferDescriptor outputDescriptor{ .usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::Storage, - .size = matrix_cols * matrix_rows * resultComponentByteSize, + .size = static_cast<uint64_t>(matrix_cols) * matrix_rows * resultComponentByteSize, }; wgpu::Buffer output = device.CreateBuffer(&outputDescriptor);
diff --git a/src/dawn/tests/end2end/SubresourceRenderAttachmentTests.cpp b/src/dawn/tests/end2end/SubresourceRenderAttachmentTests.cpp index 6e20266..75b1ff6 100644 --- a/src/dawn/tests/end2end/SubresourceRenderAttachmentTests.cpp +++ b/src/dawn/tests/end2end/SubresourceRenderAttachmentTests.cpp
@@ -97,20 +97,22 @@ const uint32_t renderTargetSize = textureSize >> baseMipLevel; switch (type) { case Type::Color: { - std::vector<utils::RGBA8> expected(renderTargetSize * renderTargetSize, - expectedColor); + std::vector<utils::RGBA8> expected( + static_cast<size_t>(renderTargetSize) * renderTargetSize, expectedColor); EXPECT_TEXTURE_EQ(expected.data(), renderTarget, {0, 0, baseArrayLayer}, {renderTargetSize, renderTargetSize}, baseMipLevel); break; } case Type::Depth: { - std::vector<float> expected(renderTargetSize * renderTargetSize, expectedDepth); + std::vector<float> expected( + static_cast<size_t>(renderTargetSize) * renderTargetSize, expectedDepth); EXPECT_TEXTURE_EQ(expected.data(), renderTarget, {0, 0, baseArrayLayer}, {renderTargetSize, renderTargetSize}, baseMipLevel); break; } case Type::Stencil: { - std::vector<uint8_t> expected(renderTargetSize * renderTargetSize, expectedStencil); + std::vector<uint8_t> expected( + static_cast<size_t>(renderTargetSize) * renderTargetSize, expectedStencil); EXPECT_TEXTURE_EQ(expected.data(), renderTarget, {0, 0, baseArrayLayer}, {renderTargetSize, renderTargetSize}, baseMipLevel, wgpu::TextureAspect::StencilOnly);
diff --git a/src/dawn/tests/end2end/Texture3DTests.cpp b/src/dawn/tests/end2end/Texture3DTests.cpp index b086ace..0d36217 100644 --- a/src/dawn/tests/end2end/Texture3DTests.cpp +++ b/src/dawn/tests/end2end/Texture3DTests.cpp
@@ -256,7 +256,7 @@ queue.Submit(1, &commands); uint32_t mipSize = std::max(kRTSize >> viewDescriptor.baseMipLevel, 1u); - std::vector<utils::RGBA8> expected(mipSize * mipSize); + std::vector<utils::RGBA8> expected(static_cast<size_t>(mipSize) * mipSize); // Only bottom-left triangle should be drawn with green color (0, 255, 0, 255), other pixels // stay red color (255, 0, 0, 255). for (uint32_t i = 0; i < mipSize; ++i) {
diff --git a/src/dawn/tests/end2end/TextureCorruptionTests.cpp b/src/dawn/tests/end2end/TextureCorruptionTests.cpp index 91de469..4e4344b 100644 --- a/src/dawn/tests/end2end/TextureCorruptionTests.cpp +++ b/src/dawn/tests/end2end/TextureCorruptionTests.cpp
@@ -116,7 +116,7 @@ } uint32_t bytesPerTexel = utils::GetTexelBlockSizeInBytes(format); uint32_t bytesPerRow = Align(levelSize.width * bytesPerTexel, 256); - uint64_t bufferSize = bytesPerRow * levelSize.height; + uint64_t bufferSize = static_cast<uint64_t>(bytesPerRow) * levelSize.height; wgpu::BufferDescriptor descriptor; descriptor.size = bufferSize; descriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst; @@ -142,7 +142,7 @@ if (bytesPerTexel >= sizeof(uint32_t)) { elementNumPerTexel = bytesPerTexel / sizeof(uint32_t); } else { - copyWidth = copyWidth * bytesPerTexel / sizeof(uint32_t); + copyWidth = static_cast<size_t>(copyWidth) * bytesPerTexel / sizeof(uint32_t); } uint32_t elementNumPerRow = bytesPerRow / sizeof(uint32_t);
diff --git a/src/dawn/tests/end2end/TextureFormatTests.cpp b/src/dawn/tests/end2end/TextureFormatTests.cpp index f634571..43104ff 100644 --- a/src/dawn/tests/end2end/TextureFormatTests.cpp +++ b/src/dawn/tests/end2end/TextureFormatTests.cpp
@@ -312,7 +312,8 @@ wgpu::BufferUsage::CopySrc); // Create the texture that we will render results to - DAWN_ASSERT(expectedRenderDataSize == width * renderFormatInfo.texelByteSize); + DAWN_ASSERT(expectedRenderDataSize == + static_cast<size_t>(width) * renderFormatInfo.texelByteSize); wgpu::TextureDescriptor renderTargetDesc; renderTargetDesc.usage = wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment;
diff --git a/src/dawn/tests/end2end/TextureViewTests.cpp b/src/dawn/tests/end2end/TextureViewTests.cpp index 3ac5965..f9f0489 100644 --- a/src/dawn/tests/end2end/TextureViewTests.cpp +++ b/src/dawn/tests/end2end/TextureViewTests.cpp
@@ -200,7 +200,7 @@ const int pixelValue = GenerateTestPixelValue(layer, level); constexpr uint32_t kPaddedTexWidth = kPixelsPerRowPitch; - std::vector<utils::RGBA8> data(kPaddedTexWidth * texHeight, + std::vector<utils::RGBA8> data(static_cast<size_t>(kPaddedTexWidth) * texHeight, utils::RGBA8(0, 0, 0, pixelValue)); wgpu::Buffer stagingBuffer = utils::CreateBufferFromData( device, data.data(), data.size() * sizeof(utils::RGBA8),
diff --git a/src/dawn/tests/end2end/TextureZeroInitTests.cpp b/src/dawn/tests/end2end/TextureZeroInitTests.cpp index 3b647e5..0abcf86 100644 --- a/src/dawn/tests/end2end/TextureZeroInitTests.cpp +++ b/src/dawn/tests/end2end/TextureZeroInitTests.cpp
@@ -246,7 +246,8 @@ EXPECT_LAZY_CLEAR(1u, queue.Submit(1, &commands)); // Expect the rendered texture to be cleared - std::vector<utils::RGBA8> expectedWithZeros(kSize * kSize, {0, 0, 0, 0}); + std::vector<utils::RGBA8> expectedWithZeros(static_cast<size_t>(kSize) * kSize, + {0, 0, 0, 0}); EXPECT_TEXTURE_EQ(expectedWithZeros.data(), renderTexture, {0, 0}, {kSize, kSize}); // Expect texture subresource initialized to be true @@ -323,7 +324,8 @@ // Expect texture subresource initialized to be true EXPECT_TRUE(native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, kArrayLayers)); - const std::vector<utils::RGBA8> kExpectedAllZero(kSize * kSize, {0, 0, 0, 0}); + const std::vector<utils::RGBA8> kExpectedAllZero(static_cast<size_t>(kSize) * kSize, + {0, 0, 0, 0}); for (uint32_t layer = 0; layer < kArrayLayers; ++layer) { EXPECT_TEXTURE_EQ(kExpectedAllZero.data(), texture, {0, 0, layer}, {kSize, kSize}); } @@ -364,7 +366,7 @@ EXPECT_LAZY_CLEAR(0u, queue.Submit(1, &commands)); uint32_t mipSize = kSize >> 2; - std::vector<utils::RGBA8> expected(mipSize * mipSize, {0, 0, 0, 0}); + std::vector<utils::RGBA8> expected(static_cast<size_t>(mipSize) * mipSize, {0, 0, 0, 0}); EXPECT_TEXTURE_EQ(expected.data(), renderPass.color, {0, 0, baseArrayLayer}, {mipSize, mipSize}, baseMipLevel); @@ -407,7 +409,7 @@ wgpu::CommandBuffer commands = encoder.Finish(); EXPECT_LAZY_CLEAR(0u, queue.Submit(1, &commands)); - std::vector<utils::RGBA8> expected(kSize * kSize, {0, 0, 0, 0}); + std::vector<utils::RGBA8> expected(static_cast<size_t>(kSize) * kSize, {0, 0, 0, 0}); EXPECT_TEXTURE_EQ(expected.data(), renderPass.color, {0, 0, baseArrayLayer}, {kSize, kSize}, baseMipLevel); @@ -428,7 +430,7 @@ kColorFormat); wgpu::Texture texture = device.CreateTexture(&descriptor); - std::vector<uint8_t> data(kFormatBlockByteSize * kSize * kSize, 100); + std::vector<uint8_t> data(kFormatBlockByteSize * static_cast<size_t>(kSize) * kSize, 100); wgpu::Buffer stagingBuffer = utils::CreateBufferFromData( device, data.data(), static_cast<uint32_t>(data.size()), wgpu::BufferUsage::CopySrc); @@ -443,7 +445,7 @@ wgpu::CommandBuffer commands = encoder.Finish(); EXPECT_LAZY_CLEAR(0u, queue.Submit(1, &commands)); - std::vector<utils::RGBA8> expected(kSize * kSize, {100, 100, 100, 100}); + std::vector<utils::RGBA8> expected(static_cast<size_t>(kSize) * kSize, {100, 100, 100, 100}); EXPECT_TEXTURE_EQ(expected.data(), texture, {0, 0}, {kSize, kSize}); @@ -466,7 +468,7 @@ kColorFormat); wgpu::Texture texture = device.CreateTexture(&descriptor); - std::vector<uint8_t> data(kFormatBlockByteSize * kSize * kSize, 100); + std::vector<uint8_t> data(kFormatBlockByteSize * static_cast<size_t>(kSize) * kSize, 100); wgpu::Buffer stagingBuffer = utils::CreateBufferFromData( device, data.data(), static_cast<uint32_t>(data.size()), wgpu::BufferUsage::CopySrc); @@ -481,8 +483,9 @@ wgpu::CommandBuffer commands = encoder.Finish(); EXPECT_LAZY_CLEAR(1u, queue.Submit(1, &commands)); - std::vector<utils::RGBA8> expected100((kSize / 2) * kSize, {100, 100, 100, 100}); - std::vector<utils::RGBA8> expectedZeros((kSize / 2) * kSize, {0, 0, 0, 0}); + std::vector<utils::RGBA8> expected100((static_cast<size_t>(kSize) / 2) * kSize, + {100, 100, 100, 100}); + std::vector<utils::RGBA8> expectedZeros((static_cast<size_t>(kSize) / 2) * kSize, {0, 0, 0, 0}); // first half filled with 100, by the buffer data EXPECT_TEXTURE_EQ(expected100.data(), texture, {0, 0}, {kSize / 2, kSize}); // second half should be cleared @@ -501,7 +504,8 @@ constexpr uint32_t kBaseArrayLayer = 2u; constexpr uint32_t kCopyLayerCount = 3u; - std::vector<uint8_t> data(kFormatBlockByteSize * kSize * kSize * kCopyLayerCount, 100); + std::vector<uint8_t> data( + kFormatBlockByteSize * static_cast<size_t>(kSize) * kSize * kCopyLayerCount, 100); wgpu::Buffer stagingBuffer = utils::CreateBufferFromData( device, data.data(), static_cast<uint32_t>(data.size()), wgpu::BufferUsage::CopySrc); @@ -523,7 +527,8 @@ EXPECT_TRUE(native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, kBaseArrayLayer, kCopyLayerCount)); - const std::vector<utils::RGBA8> expected100(kSize * kSize, {100, 100, 100, 100}); + const std::vector<utils::RGBA8> expected100(static_cast<size_t>(kSize) * kSize, + {100, 100, 100, 100}); for (uint32_t layer = kBaseArrayLayer; layer < kBaseArrayLayer + kCopyLayerCount; ++layer) { EXPECT_TEXTURE_EQ(expected100.data(), texture, {0, 0, layer}, {kSize, kSize}); } @@ -555,7 +560,7 @@ wgpu::CommandBuffer commands = encoder.Finish(); EXPECT_LAZY_CLEAR(1u, queue.Submit(1, &commands)); - std::vector<utils::RGBA8> expected(kSize * kSize, {0, 0, 0, 0}); + std::vector<utils::RGBA8> expected(static_cast<size_t>(kSize) * kSize, {0, 0, 0, 0}); EXPECT_TEXTURE_EQ(expected.data(), srcTexture, {0, 0}, {kSize, kSize}); EXPECT_TEXTURE_EQ(expected.data(), dstTexture, {0, 0}, {kSize, kSize}); @@ -577,7 +582,7 @@ // fill srcTexture with 100 { - std::vector<uint8_t> data(kFormatBlockByteSize * kSize * kSize, 100); + std::vector<uint8_t> data(kFormatBlockByteSize * static_cast<size_t>(kSize) * kSize, 100); wgpu::Buffer stagingBuffer = utils::CreateBufferFromData( device, data.data(), static_cast<uint32_t>(data.size()), wgpu::BufferUsage::CopySrc); wgpu::TexelCopyBufferInfo texelCopyBufferInfo = @@ -610,8 +615,10 @@ wgpu::CommandBuffer commands = encoder.Finish(); EXPECT_LAZY_CLEAR(1u, queue.Submit(1, &commands)); - std::vector<utils::RGBA8> expectedWithZeros((kSize / 2) * kSize, {0, 0, 0, 0}); - std::vector<utils::RGBA8> expectedWith100(kSize * kSize, {100, 100, 100, 100}); + std::vector<utils::RGBA8> expectedWithZeros((static_cast<size_t>(kSize) / 2) * kSize, + {0, 0, 0, 0}); + std::vector<utils::RGBA8> expectedWith100(static_cast<size_t>(kSize) * kSize, + {100, 100, 100, 100}); EXPECT_TEXTURE_EQ(expectedWith100.data(), srcTexture, {0, 0}, {kSize, kSize}); EXPECT_TEXTURE_EQ(expectedWith100.data(), dstTexture, {0, 0}, {kSize / 2, kSize}); @@ -660,7 +667,7 @@ EXPECT_LAZY_CLEAR(0u, queue.Submit(1, &commandBuffer)); // Expect the texture to be red because depth test passed. - std::vector<utils::RGBA8> expected(kSize * kSize, {255, 0, 0, 255}); + std::vector<utils::RGBA8> expected(static_cast<size_t>(kSize) * kSize, {255, 0, 0, 255}); EXPECT_TEXTURE_EQ(expected.data(), srcTexture, {0, 0}, {kSize, kSize}); // Expect texture subresource initialized to be true @@ -705,7 +712,7 @@ EXPECT_LAZY_CLEAR(0u, queue.Submit(1, &commandBuffer)); // Expect the texture to be red because stencil test passed. - std::vector<utils::RGBA8> expected(kSize * kSize, {255, 0, 0, 255}); + std::vector<utils::RGBA8> expected(static_cast<size_t>(kSize) * kSize, {255, 0, 0, 255}); EXPECT_TEXTURE_EQ(expected.data(), srcTexture, {0, 0}, {kSize, kSize}); // Expect texture subresource initialized to be true @@ -747,7 +754,7 @@ EXPECT_LAZY_CLEAR(0u, queue.Submit(1, &commandBuffer)); // Expect the texture to be red because both depth and stencil tests passed. - std::vector<utils::RGBA8> expected(kSize * kSize, {255, 0, 0, 255}); + std::vector<utils::RGBA8> expected(static_cast<size_t>(kSize) * kSize, {255, 0, 0, 255}); EXPECT_TEXTURE_EQ(expected.data(), srcTexture, {0, 0}, {kSize, kSize}); // Expect texture subresource initialized to be true @@ -821,7 +828,8 @@ // Expect the texture to be red because the depth and stencil tests passed. Depth was 0 // and stencil was 2. - std::vector<utils::RGBA8> expected(kSize * kSize, {255, 0, 0, 255}); + std::vector<utils::RGBA8> expected(static_cast<size_t>(kSize) * kSize, + {255, 0, 0, 255}); EXPECT_TEXTURE_EQ(expected.data(), colorTexture, {0, 0}, {kSize, kSize}); } @@ -834,7 +842,7 @@ 1, WGPUTextureAspect_StencilOnly)); // Check by copy that the stencil data is 2. - std::vector<uint8_t> expected(kSize * kSize, 2); + std::vector<uint8_t> expected(static_cast<size_t>(kSize) * kSize, 2); EXPECT_LAZY_CLEAR( 0u, EXPECT_TEXTURE_EQ(expected.data(), depthStencilTexture, {0, 0}, {kSize, kSize}, 0, wgpu::TextureAspect::StencilOnly)); @@ -892,7 +900,8 @@ // Expect the texture to be red because both the depth a stencil tests passed. // Depth was 0.7 and stencil was 0 - std::vector<utils::RGBA8> expected(kSize * kSize, {255, 0, 0, 255}); + std::vector<utils::RGBA8> expected(static_cast<size_t>(kSize) * kSize, + {255, 0, 0, 255}); EXPECT_TEXTURE_EQ(expected.data(), colorTexture, {0, 0}, {kSize, kSize}); } @@ -907,7 +916,7 @@ // TODO(chromium:42241686): Fail on the Android devices using Mali GPUs (e.g. Pixel 6). if (!(IsAndroid() && IsARM())) { // Check by copy that the stencil data is 0. - std::vector<uint8_t> expected(kSize * kSize, 0); + std::vector<uint8_t> expected(static_cast<size_t>(kSize) * kSize, 0); EXPECT_LAZY_CLEAR( 0u, EXPECT_TEXTURE_EQ(expected.data(), depthStencilTexture, {0, 0}, {kSize, kSize}, 0, wgpu::TextureAspect::StencilOnly)); @@ -974,7 +983,7 @@ } // Data should now be zero. - std::vector<uint8_t> stencilData(kSize * kSize, 0); + std::vector<uint8_t> stencilData(static_cast<size_t>(kSize) * kSize, 0); EXPECT_TEXTURE_EQ(stencilData.data(), depthStencilTexture, {0, 0}, {kSize, kSize}, 0u, wgpu::TextureAspect::StencilOnly); } @@ -1087,7 +1096,7 @@ // Check by copy that the stencil data is lazily cleared to 0. { - std::vector<uint8_t> expected(kSize * kSize, 0); + std::vector<uint8_t> expected(static_cast<size_t>(kSize) * kSize, 0); EXPECT_LAZY_CLEAR( 1u, EXPECT_TEXTURE_EQ(expected.data(), depthStencilTexture, {0, 0}, {kSize, kSize}, 0, wgpu::TextureAspect::StencilOnly)); @@ -1127,7 +1136,7 @@ // Expect the texture to be red because both the depth a stencil tests passed. // Depth was 0.3 and stencil was 0 - std::vector<utils::RGBA8> expected(kSize * kSize, {255, 0, 0, 255}); + std::vector<utils::RGBA8> expected(static_cast<size_t>(kSize) * kSize, {255, 0, 0, 255}); EXPECT_TEXTURE_EQ(expected.data(), colorTexture, {0, 0}, {kSize, kSize}); } } @@ -1147,7 +1156,7 @@ wgpu::CommandBuffer commands = encoder.Finish(); EXPECT_LAZY_CLEAR(0u, queue.Submit(1, &commands)); - std::vector<utils::RGBA8> expected(kSize * kSize, {0, 0, 0, 0}); + std::vector<utils::RGBA8> expected(static_cast<size_t>(kSize) * kSize, {0, 0, 0, 0}); EXPECT_TEXTURE_EQ(expected.data(), renderPass.color, {0, 0}, {kSize, kSize}); // Expect texture subresource initialized to be true @@ -1241,8 +1250,10 @@ queue.Submit(1, &commands); } - std::vector<utils::RGBA8> expectedZeros(kSize * kSize, utils::RGBA8::kZero); - std::vector<utils::RGBA8> expectedCleared(kSize * kSize, {128, 128, 128, 128}); + std::vector<utils::RGBA8> expectedZeros(static_cast<size_t>(kSize) * kSize, + utils::RGBA8::kZero); + std::vector<utils::RGBA8> expectedCleared(static_cast<size_t>(kSize) * kSize, + {128, 128, 128, 128}); std::vector<const std::vector<utils::RGBA8>*> expectedSlices(kNumSlices, &expectedZeros); expectedSlices[slice] = &expectedCleared; @@ -1367,8 +1378,10 @@ wgpu::CommandBuffer commands = encoder.Finish(); queue.Submit(1, &commands); - std::vector<utils::RGBA8> expectedZeros(kSize * kSize, utils::RGBA8::kZero); - std::vector<utils::RGBA8> expectedCleared(kSize * kSize, {128, 128, 128, 128}); + std::vector<utils::RGBA8> expectedZeros(static_cast<size_t>(kSize) * kSize, + utils::RGBA8::kZero); + std::vector<utils::RGBA8> expectedCleared(static_cast<size_t>(kSize) * kSize, + {128, 128, 128, 128}); std::vector<const std::vector<utils::RGBA8>*> expectedSlices(kNumSlices, &expectedZeros); expectedSlices[slice] = &expectedCleared; @@ -1586,7 +1599,7 @@ wgpu::Texture texture = device.CreateTexture(&descriptor); // Set buffer with dirty data so we know it is cleared by the lazy cleared texture copy - uint32_t bufferSize = kFormatBlockByteSize * kSize * kSize; + uint32_t bufferSize = kFormatBlockByteSize * static_cast<size_t>(kSize) * kSize; std::vector<uint8_t> data(bufferSize, 100); wgpu::Buffer bufferDst = utils::CreateBufferFromData( device, data.data(), static_cast<uint32_t>(data.size()), wgpu::BufferUsage::CopySrc); @@ -1628,7 +1641,7 @@ wgpu::Texture renderTexture = device.CreateTexture(&renderTextureDescriptor); // Fill the sample texture with data - std::vector<uint8_t> data(kFormatBlockByteSize * kSize * kSize, 1); + std::vector<uint8_t> data(kFormatBlockByteSize * static_cast<size_t>(kSize) * kSize, 1); wgpu::Buffer stagingBuffer = utils::CreateBufferFromData( device, data.data(), static_cast<uint32_t>(data.size()), wgpu::BufferUsage::CopySrc); wgpu::TexelCopyBufferInfo texelCopyBufferInfo = @@ -1670,7 +1683,7 @@ EXPECT_LAZY_CLEAR(0u, queue.Submit(1, &commands)); // Expect the rendered texture to be cleared - std::vector<utils::RGBA8> expectedWithZeros(kSize * kSize, {0, 0, 0, 0}); + std::vector<utils::RGBA8> expectedWithZeros(static_cast<size_t>(kSize) * kSize, {0, 0, 0, 0}); EXPECT_LAZY_CLEAR( 1u, EXPECT_TEXTURE_EQ(expectedWithZeros.data(), renderTexture, {0, 0}, {kSize, kSize})); @@ -1727,7 +1740,7 @@ // The depth stencil test should fail and not draw because the depth stencil texture is // cleared to 1's by using loadOp clear and set values from descriptor. - std::vector<utils::RGBA8> expectedBlack(kSize * kSize, {0, 0, 0, 0}); + std::vector<utils::RGBA8> expectedBlack(static_cast<size_t>(kSize) * kSize, {0, 0, 0, 0}); EXPECT_TEXTURE_EQ(expectedBlack.data(), srcTexture, {0, 0}, {kSize, kSize}); // Expect texture subresource initialized to be false since storeop is clear, sets @@ -1752,7 +1765,7 @@ // Now the depth stencil test should pass since depth stencil texture is cleared to 0's by // loadop load and uninitialized subresource, so we should have a red square - std::vector<utils::RGBA8> expectedRed(kSize * kSize, {255, 0, 0, 255}); + std::vector<utils::RGBA8> expectedRed(static_cast<size_t>(kSize) * kSize, {255, 0, 0, 255}); EXPECT_TEXTURE_EQ(expectedRed.data(), srcTexture, {0, 0}, {kSize, kSize}); // Expect texture subresource initialized to be false since storeop is clear, sets @@ -1782,7 +1795,7 @@ // Fill the sample texture's second mip with data uint32_t mipSize = kSize >> 1; - std::vector<uint8_t> data(kFormatBlockByteSize * mipSize * mipSize, 2); + std::vector<uint8_t> data(kFormatBlockByteSize * static_cast<size_t>(mipSize) * mipSize, 2); wgpu::Buffer stagingBuffer = utils::CreateBufferFromData( device, data.data(), static_cast<uint32_t>(data.size()), wgpu::BufferUsage::CopySrc); wgpu::TexelCopyBufferInfo texelCopyBufferInfo = @@ -1825,7 +1838,7 @@ // Expect the rendered texture to be cleared since we copied from the uninitialized first // mip. - std::vector<utils::RGBA8> expectedWithZeros(kSize * kSize, {0, 0, 0, 0}); + std::vector<utils::RGBA8> expectedWithZeros(static_cast<size_t>(kSize) * kSize, {0, 0, 0, 0}); EXPECT_LAZY_CLEAR( 1u, EXPECT_TEXTURE_EQ(expectedWithZeros.data(), renderTexture, {0, 0}, {kSize, kSize}, 0)); @@ -1834,7 +1847,8 @@ 0u, EXPECT_TEXTURE_EQ(expectedWithZeros.data(), sampleTexture, {0, 0}, {kSize, kSize}, 0)); // Expect the second mip to still be filled with 2. - std::vector<utils::RGBA8> expectedWithTwos(mipSize * mipSize, {2, 2, 2, 2}); + std::vector<utils::RGBA8> expectedWithTwos(static_cast<size_t>(mipSize) * mipSize, + {2, 2, 2, 2}); EXPECT_LAZY_CLEAR(0u, EXPECT_TEXTURE_EQ(expectedWithTwos.data(), sampleTexture, {0, 0}, {mipSize, mipSize}, 1)); @@ -1866,7 +1880,7 @@ wgpu::Texture renderTexture = device.CreateTexture(&renderTextureDescriptor); // Fill the sample texture's second array layer with data - std::vector<uint8_t> data(kFormatBlockByteSize * kSize * kSize, 2); + std::vector<uint8_t> data(kFormatBlockByteSize * static_cast<size_t>(kSize) * kSize, 2); wgpu::Buffer stagingBuffer = utils::CreateBufferFromData( device, data.data(), static_cast<uint32_t>(data.size()), wgpu::BufferUsage::CopySrc); wgpu::TexelCopyBufferInfo texelCopyBufferInfo = @@ -1915,7 +1929,7 @@ // Expect the rendered texture to be cleared since we copied from the uninitialized first // array layer. - std::vector<utils::RGBA8> expectedWithZeros(kSize * kSize, {0, 0, 0, 0}); + std::vector<utils::RGBA8> expectedWithZeros(static_cast<size_t>(kSize) * kSize, {0, 0, 0, 0}); EXPECT_LAZY_CLEAR( 1u, EXPECT_TEXTURE_EQ(expectedWithZeros.data(), renderTexture, {0, 0, 0}, {kSize, kSize})); @@ -1924,7 +1938,7 @@ 0u, EXPECT_TEXTURE_EQ(expectedWithZeros.data(), sampleTexture, {0, 0, 0}, {kSize, kSize})); // Expect the second array layer to still be filled with 2. - std::vector<utils::RGBA8> expectedWithTwos(kSize * kSize, {2, 2, 2, 2}); + std::vector<utils::RGBA8> expectedWithTwos(static_cast<size_t>(kSize) * kSize, {2, 2, 2, 2}); EXPECT_LAZY_CLEAR( 0u, EXPECT_TEXTURE_EQ(expectedWithTwos.data(), sampleTexture, {0, 0, 1}, {kSize, kSize})); @@ -1951,7 +1965,7 @@ // Create and initialize the destination buffer to ensure we only count the times of // texture lazy initialization in this test. - const uint64_t bufferSize = kUnalignedSize * bytesPerRow; + const uint64_t bufferSize = static_cast<uint64_t>(kUnalignedSize) * bytesPerRow; const std::vector<uint8_t> initialBufferData(bufferSize, 0u); wgpu::Buffer buffer = utils::CreateBufferFromData(device, initialBufferData.data(), bufferSize, wgpu::BufferUsage::CopyDst); @@ -2037,7 +2051,7 @@ // Expect texture initialized to be true EXPECT_EQ(true, native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1)); - std::vector<utils::RGBA8> expectedZeros((kSize / 2) * kSize, {0, 0, 0, 0}); + std::vector<utils::RGBA8> expectedZeros((static_cast<size_t>(kSize) / 2) * kSize, {0, 0, 0, 0}); // first half filled with 100, by the data EXPECT_TEXTURE_EQ(data.data(), texture, {0, 0}, {kSize / 2, kSize}); // second half should be cleared @@ -2120,7 +2134,7 @@ EXPECT_EQ(true, native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, kBaseArrayLayer, kCopyLayerCount)); - std::vector<utils::RGBA8> expectedZeros((kSize / 2) * kSize, {0, 0, 0, 0}); + std::vector<utils::RGBA8> expectedZeros((static_cast<size_t>(kSize) / 2) * kSize, {0, 0, 0, 0}); for (uint32_t layer = kBaseArrayLayer; layer < kBaseArrayLayer + kCopyLayerCount; ++layer) { // first half filled with 100, by the data EXPECT_TEXTURE_EQ(data.data(), texture, {0, 0, layer}, {kSize / 2, kSize}); @@ -2199,7 +2213,8 @@ // Expect texture initialized to be true EXPECT_EQ(true, native::IsTextureSubresourceInitialized(texture.Get(), kMipLevel, 1, 0, 1)); - std::vector<utils::RGBA8> expectedZeros((kMipSize / 2) * kMipSize, {0, 0, 0, 0}); + std::vector<utils::RGBA8> expectedZeros((static_cast<size_t>(kMipSize) / 2) * kMipSize, + {0, 0, 0, 0}); // first half filled with 100, by the data EXPECT_TEXTURE_EQ(data.data(), texture, {0, 0}, {kMipSize / 2, kMipSize}, kMipLevel); // second half should be cleared @@ -2307,7 +2322,7 @@ { // Full subresource must be cleared - std::vector<utils::RGBA8> expected(kTexSize * kTexSize, {0, 0, 0, 0}); + std::vector<utils::RGBA8> expected(static_cast<size_t>(kTexSize) * kTexSize, {0, 0, 0, 0}); EXPECT_TEXTURE_EQ(expected.data(), texture, {0, 0}, {kTexSize, kTexSize}, 0); } } @@ -2350,7 +2365,7 @@ { // Full subresource must be cleared - std::vector<utils::RGBA8> expected(kTexSize * kTexSize, {0, 0, 0, 0}); + std::vector<utils::RGBA8> expected(static_cast<size_t>(kTexSize) * kTexSize, {0, 0, 0, 0}); EXPECT_TEXTURE_EQ(expected.data(), texture, {0, 0}, {kTexSize, kTexSize}, 0); } } @@ -2397,7 +2412,7 @@ { // Full subresource must be cleared - std::vector<uint8_t> expected(kTexSize * kTexSize, 0); + std::vector<uint8_t> expected(static_cast<size_t>(kTexSize) * kTexSize, 0); EXPECT_TEXTURE_EQ(expected.data(), depthStencilTexture, {0, 0}, {kSize, kSize}, 0, wgpu::TextureAspect::StencilOnly); } @@ -2445,7 +2460,7 @@ { // Full subresource must be cleared - std::vector<utils::RGBA8> expected(kTexSize * kTexSize, {0, 0, 0, 0}); + std::vector<utils::RGBA8> expected(static_cast<size_t>(kTexSize) * kTexSize, {0, 0, 0, 0}); EXPECT_TEXTURE_EQ(expected.data(), resolveTex, {0, 0}, {kTexSize, kTexSize}, 0); } } @@ -2569,8 +2584,9 @@ wgpu::CommandBuffer commands = encoder.Finish(); queue.Submit(1, &commands); - std::vector<utils::RGBA8> expected(nonPaddedCopyExtent.width * nonPaddedCopyExtent.height, - {0x00, 0x20, 0x08, 0xFF}); + std::vector<utils::RGBA8> expected( + static_cast<size_t>(nonPaddedCopyExtent.width) * nonPaddedCopyExtent.height, + {0x00, 0x20, 0x08, 0xFF}); EXPECT_TEXTURE_EQ(expected.data(), renderPass.color, {0, 0}, {nonPaddedCopyExtent.width, nonPaddedCopyExtent.height}); EXPECT_TRUE(native::IsTextureSubresourceInitialized(bcTexture.Get(), viewMipmapLevel, 1, @@ -2579,7 +2595,8 @@ // If we only copied to half the texture, check the other half is initialized to black if (halfCopyTest) { std::vector<utils::RGBA8> expectBlack( - nonPaddedCopyExtent.width * nonPaddedCopyExtent.height, {0x00, 0x00, 0x00, 0xFF}); + static_cast<size_t>(nonPaddedCopyExtent.width) * nonPaddedCopyExtent.height, + {0x00, 0x00, 0x00, 0xFF}); EXPECT_TEXTURE_EQ(expectBlack.data(), renderPass.color, {copyExtent3D.width, 0}, {nonPaddedCopyExtent.width, nonPaddedCopyExtent.height}); } @@ -2877,10 +2894,11 @@ std::vector<uint8_t> expected(data.size(), 0); for (uint32_t z = 0; z < copyExtent3D.depthOrArrayLayers; ++z) { for (uint32_t y = 0; y < copyHeightInBlock; ++y) { - DAWN_UNSAFE_TODO(memcpy( - &expected[copyBytesPerRow * y + copyBytesPerRow * copyRowsPerImage * z], - &data[copyBytesPerRow * y + copyBytesPerRow * copyRowsPerImage * z], - copyWidthInBlock * utils::GetTexelBlockSizeInBytes(textureDescriptor.format))); + DAWN_UNSAFE_TODO( + memcpy(&expected[copyBytesPerRow * y + copyBytesPerRow * copyRowsPerImage * z], + &data[copyBytesPerRow * y + copyBytesPerRow * copyRowsPerImage * z], + static_cast<size_t>(copyWidthInBlock) * + utils::GetTexelBlockSizeInBytes(textureDescriptor.format))); } } // Check final contents
diff --git a/src/dawn/tests/end2end/VideoViewsTests.cpp b/src/dawn/tests/end2end/VideoViewsTests.cpp index 4d62d20..c0dbf8b 100644 --- a/src/dawn/tests/end2end/VideoViewsTests.cpp +++ b/src/dawn/tests/end2end/VideoViewsTests.cpp
@@ -403,9 +403,9 @@ std::vector<T> texelData = VideoViewsTestsBase::GetTestTextureData<T>(format, isCheckerboard, hasAlpha); auto subsampleFactor = utils::GetMultiPlaneTextureSubsamplingFactor(format, planeIndex); - uint32_t texelDataWidth = kYUVAImageDataWidthInTexels / subsampleFactor.horizontalFactor * - utils::GetMultiPlaneTextureBytesPerElement(format, planeIndex) / - sizeof(T); + uint32_t texelDataWidth = + static_cast<size_t>(kYUVAImageDataWidthInTexels) / subsampleFactor.horizontalFactor * + utils::GetMultiPlaneTextureBytesPerElement(format, planeIndex) / sizeof(T); uint32_t texelDataHeight = kYUVAImageDataHeightInTexels / subsampleFactor.verticalFactor; size_t rowPitch = bytesPerRow / sizeof(T); @@ -1841,7 +1841,8 @@ wgpu::Texture planeTexture = device.CreateTexture(&planeTextureDesc); // Copy plane (Y/UV/A) data to the plane source texture. - size_t bytesPerRow = kYUVAImageDataWidthInTexels / subsampleFactor.horizontalFactor * + size_t bytesPerRow = static_cast<size_t>(kYUVAImageDataWidthInTexels) / + subsampleFactor.horizontalFactor * utils::GetMultiPlaneTextureBytesPerElement(format, planeIndex); std::vector<T> planeSrcData = VideoViewsTestsBase::GetTestTextureDataWithPlaneIndex<T>( format, planeIndex, bytesPerRow, @@ -2283,9 +2284,10 @@ for (size_t plane = 0; plane < numPlanes; ++plane) { auto subsampleFactor = utils::GetMultiPlaneTextureSubsamplingFactor(format, plane); - size_t bytesPerRow = VideoViewsTestsBase::kYUVAImageDataWidthInTexels / - subsampleFactor.horizontalFactor * - utils::GetMultiPlaneTextureBytesPerElement(format, plane); + size_t bytesPerRow = + static_cast<size_t>(VideoViewsTestsBase::kYUVAImageDataWidthInTexels) / + subsampleFactor.horizontalFactor * + utils::GetMultiPlaneTextureBytesPerElement(format, plane); bytesPerRow = Align(bytesPerRow, 256);
diff --git a/src/dawn/tests/perf_tests/MatrixVectorMultiplyPerf.cpp b/src/dawn/tests/perf_tests/MatrixVectorMultiplyPerf.cpp index 6b22e0b..7168614 100644 --- a/src/dawn/tests/perf_tests/MatrixVectorMultiplyPerf.cpp +++ b/src/dawn/tests/perf_tests/MatrixVectorMultiplyPerf.cpp
@@ -121,7 +121,7 @@ } uint64_t GetMaxStorageBufferBindingSizeNeeded() { - return BytesPerElement() * GetParam().mRows * GetParam().mCols; + return static_cast<uint64_t>(BytesPerElement()) * GetParam().mRows * GetParam().mCols; } void GetRequiredLimits(const dawn::utils::ComboLimits& supported, @@ -191,13 +191,14 @@ wgpu::BufferDescriptor bufferDesc; bufferDesc.usage = wgpu::BufferUsage::Storage; - bufferDesc.size = BytesPerElement() * GetParam().mRows * GetParam().mCols; + bufferDesc.size = + static_cast<uint64_t>(BytesPerElement()) * GetParam().mRows * GetParam().mCols; wgpu::Buffer matrix = device.CreateBuffer(&bufferDesc); - bufferDesc.size = BytesPerElement() * GetParam().mCols; + bufferDesc.size = static_cast<uint64_t>(BytesPerElement()) * GetParam().mCols; wgpu::Buffer vector = device.CreateBuffer(&bufferDesc); - bufferDesc.size = BytesPerElement() * GetParam().mRows; + bufferDesc.size = static_cast<uint64_t>(BytesPerElement()) * GetParam().mRows; wgpu::Buffer result = device.CreateBuffer(&bufferDesc); uint32_t uniformData[] = {GetParam().mRows, /* packed cols */ GetParam().mCols / 4};
diff --git a/src/dawn/tests/perf_tests/ShaderRobustnessPerf.cpp b/src/dawn/tests/perf_tests/ShaderRobustnessPerf.cpp index e9b4d84..1276f31 100644 --- a/src/dawn/tests/perf_tests/ShaderRobustnessPerf.cpp +++ b/src/dawn/tests/perf_tests/ShaderRobustnessPerf.cpp
@@ -488,14 +488,14 @@ DAWN_TEST_UNSUPPORTED_IF((GetParam().mElemType == ElemType::F16) && !SupportsFeatures({wgpu::FeatureName::ShaderF16})); - const size_t dataASize = mDimAOuter * mDimInner; + const size_t dataASize = static_cast<size_t>(mDimAOuter) * mDimInner; std::vector<float> dataA(dataASize); uint64_t byteASize = sizeof(float) * dataA.size(); // It's ok to use all zeros to do the matrix multiplication for performance test. wgpu::Buffer bufA = utils::CreateBufferFromData(device, dataA.data(), byteASize, wgpu::BufferUsage::Storage); - const size_t dataBSize = mDimInner * mDimBOuter; + const size_t dataBSize = static_cast<size_t>(mDimInner) * mDimBOuter; std::vector<float> dataB(dataBSize); uint64_t byteBSize = sizeof(float) * dataB.size(); wgpu::Buffer bufB =
diff --git a/src/dawn/tests/perf_tests/VulkanZeroInitializeWorkgroupMemoryPerf.cpp b/src/dawn/tests/perf_tests/VulkanZeroInitializeWorkgroupMemoryPerf.cpp index 61d0cde..a32d80bc 100644 --- a/src/dawn/tests/perf_tests/VulkanZeroInitializeWorkgroupMemoryPerf.cpp +++ b/src/dawn/tests/perf_tests/VulkanZeroInitializeWorkgroupMemoryPerf.cpp
@@ -94,7 +94,7 @@ csDesc.compute.module = utils::CreateShaderModule(device, ostream.str().c_str()); mPipeline = device.CreateComputePipeline(&csDesc); - std::array<float, kWorkgroupArraySize * kNumIterations> data; + std::array<float, static_cast<size_t>(kWorkgroupArraySize) * kNumIterations> data{}; data.fill(1); wgpu::Buffer buffer = utils::CreateBufferFromData( device, data.data(), sizeof(data), wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::Storage);
diff --git a/src/dawn/tests/unittests/native/DeviceCreationTests.cpp b/src/dawn/tests/unittests/native/DeviceCreationTests.cpp index 702952d..3c20df0 100644 --- a/src/dawn/tests/unittests/native/DeviceCreationTests.cpp +++ b/src/dawn/tests/unittests/native/DeviceCreationTests.cpp
@@ -126,7 +126,7 @@ // Test successful call to CreateDevice with allocator descriptor. TEST_F(DeviceCreationTest, CreateDeviceWithAllocatorSuccess) { wgpu::DawnDeviceAllocatorControl allocationDesc = {}; - allocationDesc.allocatorHeapBlockSize = 4 * 1024; + allocationDesc.allocatorHeapBlockSize = 4ULL * 1024; wgpu::DeviceDescriptor desc = {}; wgpu::FeatureName feature = wgpu::FeatureName::DawnDeviceAllocatorControl; @@ -142,7 +142,7 @@ // not have DawnDeviceAllocatorControl feature enabled. TEST_F(DeviceCreationTest, CreateDeviceWithAllocatorFailedMissingFeature) { wgpu::DawnDeviceAllocatorControl allocationDesc = {}; - allocationDesc.allocatorHeapBlockSize = 4 * 1024; + allocationDesc.allocatorHeapBlockSize = 4ULL * 1024; wgpu::DeviceDescriptor desc = {}; desc.nextInChain = &allocationDesc;
diff --git a/src/dawn/tests/unittests/native/MemoryInstrumentationTests.cpp b/src/dawn/tests/unittests/native/MemoryInstrumentationTests.cpp index 67db9ce..3d39cf2 100644 --- a/src/dawn/tests/unittests/native/MemoryInstrumentationTests.cpp +++ b/src/dawn/tests/unittests/native/MemoryInstrumentationTests.cpp
@@ -124,7 +124,8 @@ // Byte size of entire mip chain = // ((level0 width * level0 height) + ... + (levelN width * levelN height)) * bpp * array layers. constexpr uint64_t kMipmappedTextureSize = - (((30 * 20) + (15 * 10) + (7 * 5) + (3 * 2) + (1 * 1)) * 2) * 10; // 15840 + (((30ULL * 20) + (15ULL * 10) + (7ULL * 5) + (3ULL * 2) + (1ULL * 1)) * 2ULL) * + 10ULL; // 15840 EXPECT_CALL(memoryDumpMock, AddScalar(StrEq(GetTextureLabel(mipmappedTexture)), MemoryDump::kNameSize, MemoryDump::kUnitsBytes, kMipmappedTextureSize)); @@ -140,7 +141,7 @@ }; wgpu::Texture multisampleTexture = device.CreateTexture(&kMultisampleTextureDesc); // Expected size = width(30) * height(20) * bytes per pixel(2) * sample count(4). - constexpr uint64_t kMultisampleTextureSize = 30 * 20 * 2 * 4; + constexpr uint64_t kMultisampleTextureSize = 30ULL * 20 * 2 * 4; EXPECT_CALL(memoryDumpMock, AddScalar(StrEq(GetTextureLabel(multisampleTexture)), MemoryDump::kNameSize, MemoryDump::kUnitsBytes, kMultisampleTextureSize)); @@ -157,7 +158,7 @@ }; wgpu::Texture etc2Texture = device.CreateTexture(&kETC2TextureDesc); // Expected size = (width / block width) * (height / block height) * bytes per block. - constexpr uint64_t kETC2TextureSize = (32 / 4) * (32 / 4) * 8; + constexpr uint64_t kETC2TextureSize = (32ULL / 4) * (32 / 4) * 8; EXPECT_CALL(memoryDumpMock, AddScalar(StrEq(GetTextureLabel(etc2Texture)), MemoryDump::kNameSize, MemoryDump::kUnitsBytes, kETC2TextureSize)); @@ -235,7 +236,8 @@ // Byte size of entire mip chain = // ((level0 width * level0 height) + ... + (levelN width * levelN height)) * bpp * array layers. constexpr uint64_t kMipmappedTextureSize = - (((30 * 20) + (15 * 10) + (7 * 5) + (3 * 2) + (1 * 1)) * 2) * 10; // 15840 + (((30ULL * 20) + (15ULL * 10) + (7ULL * 5) + (3ULL * 2) + (1ULL * 1)) * 2ULL) * + 10ULL; // 15840 wgpu::Texture mipmappedTextureWithOwnership = device.CreateTexture(&kMipmappedTextureDesc); mipmappedTextureWithOwnership.SetOwnershipForMemoryDump(kMipmappedTextureOwnerGUID1); @@ -379,7 +381,8 @@ // Byte size of entire mip chain = // ((level0 width * level0 height) + ... + (levelN width * levelN height)) * bpp * array layers. constexpr uint64_t kMipmappedTextureSize = - (((30 * 20) + (15 * 10) + (7 * 5) + (3 * 2) + (1 * 1)) * 2) * 10; // 15840 + (((30ULL * 20) + (15ULL * 10) + (7ULL * 5) + (3ULL * 2) + (1ULL * 1)) * 2ULL) * + 10ULL; // 15840 // Create multi-sampled textures. const wgpu::TextureDescriptor kMultisampleTextureDesc1 = { @@ -392,13 +395,13 @@ }; wgpu::Texture multisampleTexture1 = device.CreateTexture(&kMultisampleTextureDesc1); // Expected size = width(30) * height(20) * bytes per pixel(2) * sample count(4). - constexpr uint64_t kMultisampleTextureSize1 = 30 * 20 * 2 * 4; + constexpr uint64_t kMultisampleTextureSize1 = 30ULL * 20 * 2 * 4; wgpu::TextureDescriptor kMultisampleTextureDesc2 = kMultisampleTextureDesc1; kMultisampleTextureDesc2.size = {.width = 60, .height = 40}; wgpu::Texture multisampleTexture2 = device.CreateTexture(&kMultisampleTextureDesc2); // Expected size = width(60) * height(40) * bytes per pixel(2) * sample count(4). - constexpr uint64_t kMultisampleTextureSize2 = 60 * 40 * 2 * 4; + constexpr uint64_t kMultisampleTextureSize2 = 60ULL * 40 * 2 * 4; // Create a depth texture. const wgpu::TextureDescriptor kDepthTextureDesc = { @@ -409,7 +412,7 @@ }; wgpu::Texture depthTexture = device.CreateTexture(&kDepthTextureDesc); // Expected size = width(30) * height(20) * bytes per pixel(4). - constexpr uint64_t kDepthTextureSize = 30 * 20 * 4; + constexpr uint64_t kDepthTextureSize = 30ULL * 20 * 4; // Create a stencil texture. const wgpu::TextureDescriptor kStencilTextureDesc = { @@ -420,7 +423,7 @@ }; wgpu::Texture stencilTexture = device.CreateTexture(&kStencilTextureDesc); // Expected size = width(30) * height(20) * bytes per pixel(1). - constexpr uint64_t kStencilTextureSize = 30 * 20 * 1; + constexpr uint64_t kStencilTextureSize = 30ULL * 20 * 1; MemoryUsageInfo memInfo = ComputeEstimatedMemoryUsageInfo(device.Get());
diff --git a/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp b/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp index 2fdb051..b78d7fd 100644 --- a/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp
@@ -1113,7 +1113,7 @@ utils::MakeBindGroup(device, layout, {{0, buffer, 0, 256}}); // Success case, touching the end of the buffer works - utils::MakeBindGroup(device, layout, {{0, buffer, 3 * 256, 256}}); + utils::MakeBindGroup(device, layout, {{0, buffer, 3ULL * 256, 256}}); // Error case, zero size is invalid. ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 1024, 0}})); @@ -1126,10 +1126,10 @@ utils::MakeBindGroup(device, layout, {{0, buffer, 256, wgpu::kWholeSize}}); // Error case, offset is OOB - ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 256 * 5, 0}})); + ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 256ULL * 5, 0}})); // Error case, size is OOB - ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 0, 256 * 5}})); + ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 0, 256ULL * 5}})); // Error case, offset+size is OOB ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 1024, 256}}));
diff --git a/src/dawn/tests/unittests/validation/CompatValidationTests.cpp b/src/dawn/tests/unittests/validation/CompatValidationTests.cpp index 419cead..e09ecf2 100644 --- a/src/dawn/tests/unittests/validation/CompatValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/CompatValidationTests.cpp
@@ -2028,7 +2028,7 @@ wgpu::Texture texture = device.CreateTexture(&descriptor); wgpu::BufferDescriptor bufferDescriptor; - bufferDescriptor.size = 256 * 4; + bufferDescriptor.size = 256ULL * 4; bufferDescriptor.usage = wgpu::BufferUsage::CopyDst; wgpu::Buffer buffer = device.CreateBuffer(&bufferDescriptor);
diff --git a/src/dawn/tests/unittests/validation/CopyCommandsValidationTests.cpp b/src/dawn/tests/unittests/validation/CopyCommandsValidationTests.cpp index 2d23b95..e774343 100644 --- a/src/dawn/tests/unittests/validation/CopyCommandsValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/CopyCommandsValidationTests.cpp
@@ -522,8 +522,8 @@ TestB2TCopy(utils::Expectation::Success, source, 0, 256, 3, destination, 0, {5, 7, 0}, {2, 3, 1}); // Unaligned region, with buffer offset - TestB2TCopy(utils::Expectation::Success, source, 31 * 4, 256, 3, destination, 0, {0, 0, 0}, - {3, 3, 1}); + TestB2TCopy(utils::Expectation::Success, source, 31ULL * 4, 256, 3, destination, 0, + {0, 0, 0}, {3, 3, 1}); } // bytesPerRow is undefined @@ -631,7 +631,7 @@ // Test that we force Depth=1 on copies to 2D textures TEST_F(CopyCommandTest_B2T, DepthConstraintFor2DTextures) { - wgpu::Buffer source = CreateBuffer(16 * 4, wgpu::BufferUsage::CopySrc); + wgpu::Buffer source = CreateBuffer(16ULL * 4, wgpu::BufferUsage::CopySrc); wgpu::Texture destination = Create2DTexture(16, 16, 5, 1, wgpu::TextureFormat::RGBA8Unorm, wgpu::TextureUsage::CopyDst); @@ -641,8 +641,8 @@ // Test B2T copies with incorrect buffer usage TEST_F(CopyCommandTest_B2T, IncorrectUsage) { - wgpu::Buffer source = CreateBuffer(16 * 4, wgpu::BufferUsage::CopySrc); - wgpu::Buffer vertex = CreateBuffer(16 * 4, wgpu::BufferUsage::Vertex); + wgpu::Buffer source = CreateBuffer(16ULL * 4, wgpu::BufferUsage::CopySrc); + wgpu::Buffer vertex = CreateBuffer(16ULL * 4, wgpu::BufferUsage::Vertex); wgpu::Texture destination = Create2DTexture(16, 16, 5, 1, wgpu::TextureFormat::RGBA8Unorm, wgpu::TextureUsage::CopyDst); wgpu::Texture sampled = Create2DTexture(16, 16, 5, 1, wgpu::TextureFormat::RGBA8Unorm, @@ -1128,8 +1128,8 @@ TestT2BCopy(utils::Expectation::Success, source, 0, {5, 7, 0}, destination, 0, 256, 3, {2, 3, 1}); // Unaligned region, with buffer offset - TestT2BCopy(utils::Expectation::Success, source, 2, {0, 0, 0}, destination, 31 * 4, 256, 3, - {3, 3, 1}); + TestT2BCopy(utils::Expectation::Success, source, 2, {0, 0, 0}, destination, 31ULL * 4, 256, + 3, {3, 3, 1}); } // bytesPerRow is undefined
diff --git a/src/dawn/tests/unittests/validation/DrawVertexAndIndexBufferOOBValidationTests.cpp b/src/dawn/tests/unittests/validation/DrawVertexAndIndexBufferOOBValidationTests.cpp index e654d0b..3f03f47 100644 --- a/src/dawn/tests/unittests/validation/DrawVertexAndIndexBufferOOBValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/DrawVertexAndIndexBufferOOBValidationTests.cpp
@@ -302,23 +302,24 @@ // stride, buffer size, SetVertexBuffer size and offset. const std::vector<VertexBufferParams> kVertexParamsList = { // For stride = kFloat32x4Stride - {kFloat32x4Stride, 3 * kFloat32x4Stride, 0, wgpu::kWholeSize, 3}, + {kFloat32x4Stride, 3ULL * kFloat32x4Stride, 0, wgpu::kWholeSize, 3}, // Non-zero offset - {kFloat32x4Stride, 4 * kFloat32x4Stride, kFloat32x4Stride, wgpu::kWholeSize, 3}, + {kFloat32x4Stride, 4ULL * kFloat32x4Stride, kFloat32x4Stride, wgpu::kWholeSize, 3}, // Non-default size - {kFloat32x4Stride, 4 * kFloat32x4Stride, 0, 3 * kFloat32x4Stride, 3}, + {kFloat32x4Stride, 4ULL * kFloat32x4Stride, 0, 3ULL * kFloat32x4Stride, 3}, // Non-zero offset and size - {kFloat32x4Stride, 5 * kFloat32x4Stride, kFloat32x4Stride, 3 * kFloat32x4Stride, 3}, - // For stride = 2 * kFloat32x4Stride - {(2 * kFloat32x4Stride), 3 * (2 * kFloat32x4Stride), 0, wgpu::kWholeSize, 3}, + {kFloat32x4Stride, 5ULL * kFloat32x4Stride, kFloat32x4Stride, 3ULL * kFloat32x4Stride, 3}, + // For stride = 2ULL * kFloat32x4Stride + {(2ULL * kFloat32x4Stride), 3ULL * (2ULL * kFloat32x4Stride), 0, wgpu::kWholeSize, 3}, // Non-zero offset - {(2 * kFloat32x4Stride), 4 * (2 * kFloat32x4Stride), (2 * kFloat32x4Stride), + {(2ULL * kFloat32x4Stride), 4ULL * (2ULL * kFloat32x4Stride), (2ULL * kFloat32x4Stride), wgpu::kWholeSize, 3}, // Non-default size - {(2 * kFloat32x4Stride), 4 * (2 * kFloat32x4Stride), 0, 3 * (2 * kFloat32x4Stride), 3}, + {(2ULL * kFloat32x4Stride), 4ULL * (2ULL * kFloat32x4Stride), 0, + 3ULL * (2ULL * kFloat32x4Stride), 3}, // Non-zero offset and size - {(2 * kFloat32x4Stride), 5 * (2 * kFloat32x4Stride), (2 * kFloat32x4Stride), - 3 * (2 * kFloat32x4Stride), 3}, + {(2ULL * kFloat32x4Stride), 5ULL * (2ULL * kFloat32x4Stride), (2ULL * kFloat32x4Stride), + 3ULL * (2ULL * kFloat32x4Stride), 3}, // For (strideCount - 1) * arrayStride + lastStride <= bound buffer size < strideCount * // arrayStride {(kFloat32x4Stride + 4), 2 * (kFloat32x4Stride + 4) + kFloat32x4Stride, 0, wgpu::kWholeSize, @@ -329,23 +330,24 @@ // Parameters list for instance-step-mode buffer. const std::vector<VertexBufferParams> kInstanceParamsList = { // For stride = kFloat32x2Stride - {kFloat32x2Stride, 5 * kFloat32x2Stride, 0, wgpu::kWholeSize, 5}, + {kFloat32x2Stride, 5ULL * kFloat32x2Stride, 0, wgpu::kWholeSize, 5}, // Non-zero offset - {kFloat32x2Stride, 6 * kFloat32x2Stride, kFloat32x2Stride, wgpu::kWholeSize, 5}, + {kFloat32x2Stride, 6ULL * kFloat32x2Stride, kFloat32x2Stride, wgpu::kWholeSize, 5}, // Non-default size - {kFloat32x2Stride, 6 * kFloat32x2Stride, 0, 5 * kFloat32x2Stride, 5}, + {kFloat32x2Stride, 6ULL * kFloat32x2Stride, 0, 5ULL * kFloat32x2Stride, 5}, // Non-zero offset and size - {kFloat32x2Stride, 7 * kFloat32x2Stride, kFloat32x2Stride, 5 * kFloat32x2Stride, 5}, - // For stride = 3 * kFloat32x2Stride - {(3 * kFloat32x2Stride), 5 * (3 * kFloat32x2Stride), 0, wgpu::kWholeSize, 5}, + {kFloat32x2Stride, 7ULL * kFloat32x2Stride, kFloat32x2Stride, 5ULL * kFloat32x2Stride, 5}, + // For stride = 3ULL * kFloat32x2Stride + {(3ULL * kFloat32x2Stride), 5ULL * (3ULL * kFloat32x2Stride), 0, wgpu::kWholeSize, 5}, // Non-zero offset - {(3 * kFloat32x2Stride), 6 * (3 * kFloat32x2Stride), (3 * kFloat32x2Stride), + {(3ULL * kFloat32x2Stride), 6ULL * (3ULL * kFloat32x2Stride), (3ULL * kFloat32x2Stride), wgpu::kWholeSize, 5}, // Non-default size - {(3 * kFloat32x2Stride), 6 * (3 * kFloat32x2Stride), 0, 5 * (3 * kFloat32x2Stride), 5}, + {(3ULL * kFloat32x2Stride), 6ULL * (3ULL * kFloat32x2Stride), 0, + 5ULL * (3ULL * kFloat32x2Stride), 5}, // Non-zero offset and size - {(3 * kFloat32x2Stride), 7 * (3 * kFloat32x2Stride), (3 * kFloat32x2Stride), - 5 * (3 * kFloat32x2Stride), 5}, + {(3ULL * kFloat32x2Stride), 7ULL * (3ULL * kFloat32x2Stride), (3ULL * kFloat32x2Stride), + 5ULL * (3ULL * kFloat32x2Stride), 5}, // For (strideCount - 1) * arrayStride + lastStride <= bound buffer size < strideCount * // arrayStride {(kFloat32x2Stride + 4), 2 * (kFloat32x2Stride + 4) + kFloat32x2Stride, 0, wgpu::kWholeSize, @@ -363,7 +365,7 @@ TEST_F(DrawVertexAndIndexBufferOOBValidationTests, DrawBasic) { wgpu::RenderPipeline pipeline = CreateBasicRenderPipeline(); - wgpu::Buffer vertexBuffer = CreateBuffer(3 * kFloat32x4Stride); + wgpu::Buffer vertexBuffer = CreateBuffer(3ULL * kFloat32x4Stride); { // Implicit size @@ -461,7 +463,7 @@ wgpu::RenderPipeline pipeline = CreateRenderPipelineWithBufferDesc({{kFloat32x4Stride, wgpu::VertexStepMode::Vertex, {}}}); - wgpu::Buffer vertexBuffer = CreateBuffer(3 * kFloat32x4Stride); + wgpu::Buffer vertexBuffer = CreateBuffer(3ULL * kFloat32x4Stride); { // Valid @@ -479,7 +481,7 @@ // Verify vertex buffers don't need to be set to unused (hole) slots for Draw TEST_F(DrawVertexAndIndexBufferOOBValidationTests, UnusedSlots) { // Set vertex buffer only to the second slot - wgpu::Buffer vertexBuffer = CreateBuffer(3 * kFloat32x4Stride); + wgpu::Buffer vertexBuffer = CreateBuffer(3ULL * kFloat32x4Stride); VertexBufferList vertexBufferList = {{1, vertexBuffer, 0, wgpu::kWholeSize}}; { @@ -507,7 +509,7 @@ wgpu::Buffer indexBuffer = CreateBuffer(12 * sizeof(uint32_t), wgpu::BufferUsage::Index); // Build vertex buffer for 3 vertices - wgpu::Buffer vertexBuffer = CreateBuffer(3 * kFloat32x4Stride); + wgpu::Buffer vertexBuffer = CreateBuffer(3ULL * kFloat32x4Stride); VertexBufferList vertexBufferList = {{0, vertexBuffer, 0, wgpu::kWholeSize}}; IndexBufferDesc indexBufferDesc = {indexBuffer, wgpu::IndexFormat::Uint32}; @@ -525,9 +527,9 @@ // Build index buffer use given params wgpu::Buffer indexBuffer = CreateBuffer(params.indexBufferSize, wgpu::BufferUsage::Index); // Build vertex buffer for 3 vertices - wgpu::Buffer vertexBuffer = CreateBuffer(3 * kFloat32x4Stride); + wgpu::Buffer vertexBuffer = CreateBuffer(3ULL * kFloat32x4Stride); // Build vertex buffer for 5 instances - wgpu::Buffer instanceBuffer = CreateBuffer(5 * kFloat32x2Stride); + wgpu::Buffer instanceBuffer = CreateBuffer(5ULL * kFloat32x2Stride); VertexBufferList vertexBufferList = {{0, vertexBuffer, 0, wgpu::kWholeSize}, {1, instanceBuffer, 0, wgpu::kWholeSize}}; @@ -576,7 +578,7 @@ constexpr uint64_t indexStride = sizeof(uint32_t); // Build index buffer for 12 indexes - wgpu::Buffer indexBuffer = CreateBuffer(12 * indexStride, wgpu::BufferUsage::Index); + wgpu::Buffer indexBuffer = CreateBuffer(12ULL * indexStride, wgpu::BufferUsage::Index); // Build vertex buffer for vertices wgpu::Buffer vertexBuffer = CreateBuffer(vertexParams.bufferSize); // Build vertex buffer for instances @@ -629,10 +631,10 @@ IndexBufferDesc indexBufferDesc = {indexBuffer, wgpu::IndexFormat::Uint32}; // Build vertex buffer for 3 vertices - wgpu::Buffer vertexBuffer = CreateBuffer(3 * kFloat32x4Stride); + wgpu::Buffer vertexBuffer = CreateBuffer(3ULL * kFloat32x4Stride); // Build vertex buffer for 3 instances - wgpu::Buffer instanceBuffer = CreateBuffer(3 * kFloat32x2Stride); + wgpu::Buffer instanceBuffer = CreateBuffer(3ULL * kFloat32x2Stride); { // Valid @@ -658,8 +660,8 @@ IndexBufferDesc indexBufferDesc = {indexBuffer, wgpu::IndexFormat::Uint32}; // Set vertex buffers only to the second and third slots - wgpu::Buffer vertexBuffer = CreateBuffer(3 * kFloat32x4Stride); - wgpu::Buffer instanceBuffer = CreateBuffer(3 * kFloat32x2Stride); + wgpu::Buffer vertexBuffer = CreateBuffer(3ULL * kFloat32x4Stride); + wgpu::Buffer instanceBuffer = CreateBuffer(3ULL * kFloat32x2Stride); VertexBufferList vertexBufferList = {{1, vertexBuffer, 0, wgpu::kWholeSize}, {2, instanceBuffer, 0, wgpu::kWholeSize}}; @@ -732,7 +734,7 @@ constexpr uint64_t indexStride = sizeof(uint32_t); // Build index buffer for 12 indexes - wgpu::Buffer indexBuffer = CreateBuffer(12 * indexStride, wgpu::BufferUsage::Index); + wgpu::Buffer indexBuffer = CreateBuffer(12ULL * indexStride, wgpu::BufferUsage::Index); // Build vertex buffer for vertices wgpu::Buffer vertexBuffer = CreateBuffer(vertexParams.bufferSize); // Build vertex buffer for instances @@ -888,17 +890,17 @@ uint32_t indexStride = sizeof(uint32_t); // Build index buffer for 11 indexes - wgpu::Buffer indexBuffer11 = CreateBuffer(11 * indexStride, wgpu::BufferUsage::Index); + wgpu::Buffer indexBuffer11 = CreateBuffer(11ULL * indexStride, wgpu::BufferUsage::Index); // Build index buffer for 12 indexes - wgpu::Buffer indexBuffer12 = CreateBuffer(12 * indexStride, wgpu::BufferUsage::Index); + wgpu::Buffer indexBuffer12 = CreateBuffer(12ULL * indexStride, wgpu::BufferUsage::Index); // Build vertex buffer for 2 vertices - wgpu::Buffer vertexBuffer2 = CreateBuffer(2 * kFloat32x4Stride); + wgpu::Buffer vertexBuffer2 = CreateBuffer(2ULL * kFloat32x4Stride); // Build vertex buffer for 3 vertices - wgpu::Buffer vertexBuffer3 = CreateBuffer(3 * kFloat32x4Stride); + wgpu::Buffer vertexBuffer3 = CreateBuffer(3ULL * kFloat32x4Stride); // Build vertex buffer for 4 instances - wgpu::Buffer instanceBuffer4 = CreateBuffer(4 * kFloat32x2Stride); + wgpu::Buffer instanceBuffer4 = CreateBuffer(4ULL * kFloat32x2Stride); // Build vertex buffer for 5 instances - wgpu::Buffer instanceBuffer5 = CreateBuffer(5 * kFloat32x2Stride); + wgpu::Buffer instanceBuffer5 = CreateBuffer(5ULL * kFloat32x2Stride); // Test for setting vertex buffer for multiple times {
diff --git a/src/dawn/tests/unittests/validation/TexelBufferValidationTests.cpp b/src/dawn/tests/unittests/validation/TexelBufferValidationTests.cpp index 9f02509..4d83d32 100644 --- a/src/dawn/tests/unittests/validation/TexelBufferValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/TexelBufferValidationTests.cpp
@@ -119,7 +119,7 @@ // BindingInitializationHelper should chain a TexelBufferBindingEntry when initialized // with a TexelBufferView. TEST_F(TexelBufferValidationTest, BindingHelperChainsTexelBufferBindingEntry) { - constexpr uint64_t kSize = 4 * 4; + constexpr uint64_t kSize = 4ULL * 4; wgpu::Buffer buffer = CreateTexelBuffer(kSize, wgpu::BufferUsage::TexelBuffer); wgpu::TexelBufferViewDescriptor viewDesc; @@ -144,7 +144,7 @@ // Creating a bind group without chaining a TexelBufferBindingEntry fails. TEST_F(TexelBufferValidationTest, BindGroupMissingTexelBufferBindingEntry) { - constexpr uint64_t kSize = 4 * 4; + constexpr uint64_t kSize = 4ULL * 4; wgpu::Buffer buffer = CreateTexelBuffer(kSize, wgpu::BufferUsage::TexelBuffer); TexelBufferLayoutDescriptor helper(wgpu::TexelBufferAccess::ReadOnly,
diff --git a/src/dawn/tests/unittests/validation/TextureViewValidationTests.cpp b/src/dawn/tests/unittests/validation/TextureViewValidationTests.cpp index e012510..1501f0b 100644 --- a/src/dawn/tests/unittests/validation/TextureViewValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/TextureViewValidationTests.cpp
@@ -1276,7 +1276,7 @@ // Valid texel buffer view creation TEST_F(TexelBufferViewValidationTest, CreationSuccess) { - constexpr uint64_t kSize = 4 * 4; // 4 texels of RGBA8Uint + constexpr uint64_t kSize = 4ULL * 4; // 4 texels of RGBA8Uint wgpu::Buffer buffer = CreateTexelBuffer(kSize, wgpu::BufferUsage::TexelBuffer | wgpu::BufferUsage::CopySrc);
diff --git a/src/dawn/tests/white_box/D3D12ResourceHeapTests.cpp b/src/dawn/tests/white_box/D3D12ResourceHeapTests.cpp index 72d0cb8..13e5466 100644 --- a/src/dawn/tests/white_box/D3D12ResourceHeapTests.cpp +++ b/src/dawn/tests/white_box/D3D12ResourceHeapTests.cpp
@@ -92,7 +92,7 @@ TEST_P(D3D12ResourceHeapTests, AlignUBO) { // Create a small UBO wgpu::BufferDescriptor descriptor; - descriptor.size = 4 * 1024; + descriptor.size = 4ULL * 1024; descriptor.usage = wgpu::BufferUsage::Uniform; wgpu::Buffer buffer = device.CreateBuffer(&descriptor);
diff --git a/src/dawn/tests/white_box/SharedBufferMemoryTests.cpp b/src/dawn/tests/white_box/SharedBufferMemoryTests.cpp index 3bca380..76a87db 100644 --- a/src/dawn/tests/white_box/SharedBufferMemoryTests.cpp +++ b/src/dawn/tests/white_box/SharedBufferMemoryTests.cpp
@@ -779,7 +779,7 @@ memory.BeginAccess(buffer, &beginAccessDesc); constexpr uint32_t bufferData[] = {kBufferData, kBufferData}; - wgpu::Buffer srcBuffer = utils::CreateBufferFromData(device, bufferData, kBufferSize * 2, + wgpu::Buffer srcBuffer = utils::CreateBufferFromData(device, bufferData, kBufferSize * 2ULL, wgpu::BufferUsage::CopySrc); wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); encoder.CopyBufferToBuffer(srcBuffer, 0, buffer, 0, 4);
diff --git a/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp b/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp index 4e421df..64045a56 100644 --- a/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp +++ b/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp
@@ -1742,8 +1742,9 @@ alphaVal = 255; break; } - std::vector<utils::RGBA8> expected(texture.GetWidth() * texture.GetHeight(), - utils::RGBA8{0, 0, 0, alphaVal}); + std::vector<utils::RGBA8> expected( + static_cast<size_t>(texture.GetWidth()) * texture.GetHeight(), + utils::RGBA8{0, 0, 0, alphaVal}); EXPECT_TEXTURE_EQ(device, expected.data(), colorTarget, {0, 0}, {colorTarget.GetWidth(), colorTarget.GetHeight()}) << "format: " << static_cast<uint32_t>(properties.format);
diff --git a/src/dawn/tests/white_box/VulkanImageWrappingTests.cpp b/src/dawn/tests/white_box/VulkanImageWrappingTests.cpp index 811d876..dd7e74b 100644 --- a/src/dawn/tests/white_box/VulkanImageWrappingTests.cpp +++ b/src/dawn/tests/white_box/VulkanImageWrappingTests.cpp
@@ -854,10 +854,13 @@ float normCol = static_cast<float>(col) / width; float dist = sqrt(normRow * normRow + normCol * normCol) * 3; dist = dist - static_cast<int>(dist); - data[4 * (row * width + col)] = static_cast<unsigned char>(dist * 255); - data[4 * (row * width + col) + 1] = static_cast<unsigned char>(dist * 255); - data[4 * (row * width + col) + 2] = static_cast<unsigned char>(dist * 255); - data[4 * (row * width + col) + 3] = 255; + data[static_cast<size_t>(4) * (row * width + col)] = + static_cast<unsigned char>(dist * 255); + data[static_cast<size_t>(4) * (row * width + col) + 1] = + static_cast<unsigned char>(dist * 255); + data[static_cast<size_t>(4) * (row * width + col) + 2] = + static_cast<unsigned char>(dist * 255); + data[static_cast<size_t>(4) * (row * width + col) + 3] = 255; } }
diff --git a/src/dawn/wire/client/Queue.cpp b/src/dawn/wire/client/Queue.cpp index 6b16c39..c93ed3c 100644 --- a/src/dawn/wire/client/Queue.cpp +++ b/src/dawn/wire/client/Queue.cpp
@@ -42,7 +42,7 @@ namespace { // Buffer and Texture uploads larger than 4Mb use a different path optimized for larger transfers. -const uint64_t kWriteXLThreshold = 1024 * 1024 * 4; +const uint64_t kWriteXLThreshold = 1024ULL * 1024 * 4; class WorkDoneEvent : public TrackedEvent { public:
diff --git a/src/tint/lang/core/ir/const_param_validator.cc b/src/tint/lang/core/ir/const_param_validator.cc index 2fcd8de..9c92c5d 100644 --- a/src/tint/lang/core/ir/const_param_validator.cc +++ b/src/tint/lang/core/ir/const_param_validator.cc
@@ -509,7 +509,8 @@ } // Note: Offset and stride are in bytes. - uint64_t mat_required_size = offset + stride * (major_size - 1) + minor_size * ele_ty->Size(); + uint64_t mat_required_size = offset + static_cast<uint64_t>(stride) * (major_size - 1) + + static_cast<uint64_t>(minor_size) * ele_ty->Size(); // Round up to scalar size. mat_required_size = RoundUp(stride_factor, mat_required_size); if (mat_required_size > std::numeric_limits<uint32_t>::max()) {
diff --git a/src/tint/lang/wgsl/resolver/resolver.cc b/src/tint/lang/wgsl/resolver/resolver.cc index f30c238..653e97e 100644 --- a/src/tint/lang/wgsl/resolver/resolver.cc +++ b/src/tint/lang/wgsl/resolver/resolver.cc
@@ -1586,7 +1586,8 @@ mat_ty = call->Arguments()[2]->Type()->As<core::type::SubgroupMatrix>(); } - uint64_t mat_required_size = mat_ty->Rows() * mat_ty->Columns() * mat_ty->Type()->Size(); + uint64_t mat_required_size = + static_cast<uint64_t>(mat_ty->Rows()) * mat_ty->Columns() * mat_ty->Type()->Size(); auto* root = pointer->RootIdentifier(); mat_required_size += FindSubgroupMatrixStructOffset(pointer);
diff --git a/src/tint/lang/wgsl/resolver/validator.cc b/src/tint/lang/wgsl/resolver/validator.cc index 119cef9..27ccd17 100644 --- a/src/tint/lang/wgsl/resolver/validator.cc +++ b/src/tint/lang/wgsl/resolver/validator.cc
@@ -2359,8 +2359,8 @@ return true; } - uint64_t mat_required_size = - stride_value * (major_size - 1) + minor_size * ele_ty->Size() + offset_value; + uint64_t mat_required_size = stride_value * (major_size - 1) + + static_cast<uint64_t>(minor_size) * ele_ty->Size() + offset_value; uint64_t arr_size = ptr_arr_ty->Size(); if (arr_size < mat_required_size) { AddError(call->Declaration()->source)
diff --git a/src/tint/utils/internal_limits.h b/src/tint/utils/internal_limits.h index 503c695..51a4229 100644 --- a/src/tint/utils/internal_limits.h +++ b/src/tint/utils/internal_limits.h
@@ -51,7 +51,7 @@ constexpr int64_t kQuadSize = 4; // A @size attribute maximum size -constexpr int64_t kMaxStructMemberPadding = 10 * 1024 * 1024; +constexpr int64_t kMaxStructMemberPadding = 10LL * 1024 * 1024; // The maximum number of locations allowed for shader IO. // This hard limit is derived from spirv-val (kMaxLocations in
diff --git a/src/tint/utils/memory/bump_allocator.h b/src/tint/utils/memory/bump_allocator.h index cadbeda..6cf31ac 100644 --- a/src/tint/utils/memory/bump_allocator.h +++ b/src/tint/utils/memory/bump_allocator.h
@@ -61,7 +61,7 @@ public: /// The default size for a block's data. Allocations can be greater than this, but smaller /// allocations will use this size. - static constexpr size_t kDefaultBlockDataSize = 64 * 1024; + static constexpr size_t kDefaultBlockDataSize = 64ULL * 1024; /// Constructor BumpAllocator() = default;
diff --git a/src/utils/heap_array_test.cc b/src/utils/heap_array_test.cc index d216bf6..e9f4008 100644 --- a/src/utils/heap_array_test.cc +++ b/src/utils/heap_array_test.cc
@@ -241,7 +241,7 @@ // HeapArray is freed when it goes out of scope. Requires 512MiB of memory if working. // Should OOM (at least on systems without ridiculous amounts of memory) if broken. TEST_F(HeapArrayTest, FreedByScope) { - constexpr size_t k512MiB = 256 * 1024 * 1024; + constexpr size_t k512MiB = static_cast<size_t>(512) * 1024 * 1024; constexpr uint64_t kAllocateTotal = sizeof(size_t) > sizeof(uint32_t) ? 0x100'0000'0000 // 1 TiB : 0x1'0000'0000; // 4 GiB @@ -260,7 +260,7 @@ // HeapArray is freed when assigned over. Requires 512MiB of memory if working. // Should OOM (at least on systems without ridiculous amounts of memory) if broken. TEST_F(HeapArrayTest, FreedByAssignment) { - constexpr size_t k256MiB = 256 * 1024 * 1024; + constexpr size_t k256MiB = static_cast<size_t>(256) * 1024 * 1024; constexpr uint64_t kAllocateTotal = sizeof(size_t) > sizeof(uint32_t) ? 0x100'0000'0000 // 1 TiB : 0x1'0000'0000; // 4 GiB