Use C++17 structured binding in more places.
Bug: dawn:824
Change-Id: Ie39d4f622bfb3dcc3a74b03d594efcea7139a9dc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75069
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/common/ConcurrentCache.h b/src/common/ConcurrentCache.h
index 0e93ddd..a1cab8d 100644
--- a/src/common/ConcurrentCache.h
+++ b/src/common/ConcurrentCache.h
@@ -37,8 +37,8 @@
std::pair<T*, bool> Insert(T* object) {
std::lock_guard<std::mutex> lock(mMutex);
- auto insertion = mCache.insert(object);
- return std::make_pair(*(insertion.first), insertion.second);
+ auto [value, inserted] = mCache.insert(object);
+ return {*value, inserted};
}
size_t Erase(T* object) {
diff --git a/src/dawn_native/AsyncTask.cpp b/src/dawn_native/AsyncTask.cpp
index 84f8764..c00d16e 100644
--- a/src/dawn_native/AsyncTask.cpp
+++ b/src/dawn_native/AsyncTask.cpp
@@ -46,8 +46,8 @@
allPendingTasks.swap(mPendingTasks);
}
- for (auto& keyValue : allPendingTasks) {
- keyValue.second->waitableEvent->Wait();
+ for (auto& [_, task] : allPendingTasks) {
+ task->waitableEvent->Wait();
}
}
diff --git a/src/dawn_native/BindGroupLayout.cpp b/src/dawn_native/BindGroupLayout.cpp
index 0e6d15f..c56f0ac 100644
--- a/src/dawn_native/BindGroupLayout.cpp
+++ b/src/dawn_native/BindGroupLayout.cpp
@@ -382,8 +382,8 @@
}
IncrementBindingCounts(&mBindingCounts, binding);
- const auto& it = mBindingMap.emplace(BindingNumber(binding.binding), i);
- ASSERT(it.second);
+ const auto& [_, inserted] = mBindingMap.emplace(BindingNumber(binding.binding), i);
+ ASSERT(inserted);
}
ASSERT(CheckBufferBindingsFirst({mBindingInfo.data(), GetBindingCount()}));
ASSERT(mBindingInfo.size() <= kMaxBindingsPerPipelineLayoutTyped);
@@ -445,11 +445,10 @@
// std::map is sorted by key, so two BGLs constructed in different orders
// will still record the same.
- for (const auto& it : mBindingMap) {
- recorder.Record(it.first, it.second);
+ for (const auto [id, index] : mBindingMap) {
+ recorder.Record(id, index);
- const BindingInfo& info = mBindingInfo[it.second];
-
+ const BindingInfo& info = mBindingInfo[index];
recorder.Record(info.buffer.hasDynamicOffset, info.visibility, info.bindingType,
info.buffer.type, info.buffer.minBindingSize, info.sampler.type,
info.texture.sampleType, info.texture.viewDimension,
diff --git a/src/dawn_native/Device.cpp b/src/dawn_native/Device.cpp
index 90af4cf..cdaaaa7 100644
--- a/src/dawn_native/Device.cpp
+++ b/src/dawn_native/Device.cpp
@@ -748,23 +748,23 @@
Ref<ComputePipelineBase> DeviceBase::AddOrGetCachedComputePipeline(
Ref<ComputePipelineBase> computePipeline) {
- auto insertion = mCaches->computePipelines.insert(computePipeline.Get());
- if (insertion.second) {
+ auto [cachedPipeline, inserted] = mCaches->computePipelines.insert(computePipeline.Get());
+ if (inserted) {
computePipeline->SetIsCachedReference();
return computePipeline;
} else {
- return *(insertion.first);
+ return *cachedPipeline;
}
}
Ref<RenderPipelineBase> DeviceBase::AddOrGetCachedRenderPipeline(
Ref<RenderPipelineBase> renderPipeline) {
- auto insertion = mCaches->renderPipelines.insert(renderPipeline.Get());
- if (insertion.second) {
+ auto [cachedPipeline, inserted] = mCaches->renderPipelines.insert(renderPipeline.Get());
+ if (inserted) {
renderPipeline->SetIsCachedReference();
return renderPipeline;
} else {
- return *(insertion.first);
+ return *cachedPipeline;
}
}
diff --git a/src/dawn_native/Features.cpp b/src/dawn_native/Features.cpp
index 913706c..75b2266 100644
--- a/src/dawn_native/Features.cpp
+++ b/src/dawn_native/Features.cpp
@@ -256,9 +256,9 @@
{"timestamp_query", "timestamp-query"},
{"multiplanar_formats", "multiplanar-formats"},
}};
- for (const auto& replacement : kReplacementsForDeprecatedNames) {
- if (strcmp(featureName, replacement.first) == 0) {
- return FeatureNameToEnum(replacement.second);
+ for (const auto& [name, replacement] : kReplacementsForDeprecatedNames) {
+ if (strcmp(featureName, name) == 0) {
+ return FeatureNameToEnum(replacement);
}
}
diff --git a/src/dawn_native/IndirectDrawMetadata.cpp b/src/dawn_native/IndirectDrawMetadata.cpp
index 9d514f3..40f144b 100644
--- a/src/dawn_native/IndirectDrawMetadata.cpp
+++ b/src/dawn_native/IndirectDrawMetadata.cpp
@@ -139,22 +139,21 @@
}
void IndirectDrawMetadata::AddBundle(RenderBundleBase* bundle) {
- auto result = mAddedBundles.insert(bundle);
- if (!result.second) {
+ auto [_, inserted] = mAddedBundles.insert(bundle);
+ if (!inserted) {
return;
}
- for (const auto& entry :
+ for (const auto& [config, validationInfo] :
bundle->GetIndirectDrawMetadata().mIndexedIndirectBufferValidationInfo) {
- const IndexedIndirectConfig& config = entry.first;
auto it = mIndexedIndirectBufferValidationInfo.lower_bound(config);
if (it != mIndexedIndirectBufferValidationInfo.end() && it->first == config) {
// We already have batches for the same config. Merge the new ones in.
- for (const IndexedIndirectValidationBatch& batch : entry.second.GetBatches()) {
+ for (const IndexedIndirectValidationBatch& batch : validationInfo.GetBatches()) {
it->second.AddBatch(mMaxDrawCallsPerBatch, mMaxBatchOffsetRange, batch);
}
} else {
- mIndexedIndirectBufferValidationInfo.emplace_hint(it, config, entry.second);
+ mIndexedIndirectBufferValidationInfo.emplace_hint(it, config, validationInfo);
}
}
}
diff --git a/src/dawn_native/IndirectDrawValidationEncoder.cpp b/src/dawn_native/IndirectDrawValidationEncoder.cpp
index 36c8d0a..5e63094 100644
--- a/src/dawn_native/IndirectDrawValidationEncoder.cpp
+++ b/src/dawn_native/IndirectDrawValidationEncoder.cpp
@@ -230,11 +230,10 @@
const uint32_t minStorageBufferOffsetAlignment =
device->GetLimits().v1.minStorageBufferOffsetAlignment;
- for (auto& entry : bufferInfoMap) {
- const IndirectDrawMetadata::IndexedIndirectConfig& config = entry.first;
+ for (auto& [config, validationInfo] : bufferInfoMap) {
BufferBase* clientIndirectBuffer = config.first;
for (const IndirectDrawMetadata::IndexedIndirectValidationBatch& batch :
- entry.second.GetBatches()) {
+ validationInfo.GetBatches()) {
const uint64_t minOffsetFromAlignedBoundary =
batch.minOffset % minStorageBufferOffsetAlignment;
const uint64_t minOffsetAlignedDown =
diff --git a/src/dawn_native/PassResourceUsageTracker.cpp b/src/dawn_native/PassResourceUsageTracker.cpp
index 470eee17..46ceda7 100644
--- a/src/dawn_native/PassResourceUsageTracker.cpp
+++ b/src/dawn_native/PassResourceUsageTracker.cpp
@@ -154,14 +154,14 @@
result.textures.reserve(mTextureUsages.size());
result.textureUsages.reserve(mTextureUsages.size());
- for (auto& it : mBufferUsages) {
- result.buffers.push_back(it.first);
- result.bufferUsages.push_back(it.second);
+ for (auto& [buffer, usage] : mBufferUsages) {
+ result.buffers.push_back(buffer);
+ result.bufferUsages.push_back(usage);
}
- for (auto& it : mTextureUsages) {
- result.textures.push_back(it.first);
- result.textureUsages.push_back(std::move(it.second));
+ for (auto& [texture, usage] : mTextureUsages) {
+ result.textures.push_back(texture);
+ result.textureUsages.push_back(std::move(usage));
}
for (auto& it : mExternalTextureUsages) {
diff --git a/src/dawn_native/PipelineLayout.cpp b/src/dawn_native/PipelineLayout.cpp
index 2851695..27e3801 100644
--- a/src/dawn_native/PipelineLayout.cpp
+++ b/src/dawn_native/PipelineLayout.cpp
@@ -235,8 +235,8 @@
-> ResultOrError<Ref<BindGroupLayoutBase>> {
std::vector<BindGroupLayoutEntry> entryVec;
entryVec.reserve(entries.size());
- for (auto& it : entries) {
- entryVec.push_back(it.second);
+ for (auto& [_, entry] : entries) {
+ entryVec.push_back(entry);
}
BindGroupLayoutDescriptor desc = {};
@@ -268,10 +268,7 @@
const EntryPointMetadata& metadata = stage.module->GetEntryPoint(stage.entryPoint);
for (BindGroupIndex group(0); group < metadata.bindings.size(); ++group) {
- for (const auto& bindingIt : metadata.bindings[group]) {
- BindingNumber bindingNumber = bindingIt.first;
- const ShaderBindingInfo& shaderBinding = bindingIt.second;
-
+ for (const auto& [bindingNumber, shaderBinding] : metadata.bindings[group]) {
// Create the BindGroupLayoutEntry
BindGroupLayoutEntry entry =
ConvertMetadataToEntry(shaderBinding, &externalTextureBindingLayout);
@@ -280,9 +277,10 @@
// Add it to our map of all entries, if there is an existing entry, then we
// need to merge, if we can.
- const auto& insertion = entryData[group].insert({bindingNumber, entry});
- if (!insertion.second) {
- DAWN_TRY(MergeEntries(&insertion.first->second, entry));
+ const auto& [existingEntry, inserted] =
+ entryData[group].insert({bindingNumber, entry});
+ if (!inserted) {
+ DAWN_TRY(MergeEntries(&existingEntry->second, entry));
}
}
}
diff --git a/src/dawn_native/QuerySet.cpp b/src/dawn_native/QuerySet.cpp
index fbe3856..37d8a99 100644
--- a/src/dawn_native/QuerySet.cpp
+++ b/src/dawn_native/QuerySet.cpp
@@ -73,9 +73,9 @@
for (uint32_t i = 0; i < descriptor->pipelineStatisticsCount; i++) {
DAWN_TRY(ValidatePipelineStatisticName(descriptor->pipelineStatistics[i]));
- std::pair<std::set<wgpu::PipelineStatisticName>::iterator, bool> res =
+ auto [_, inserted] =
pipelineStatisticsSet.insert((descriptor->pipelineStatistics[i]));
- DAWN_INVALID_IF(!res.second, "Statistic %s is specified more than once.",
+ DAWN_INVALID_IF(!inserted, "Statistic %s is specified more than once.",
descriptor->pipelineStatistics[i]);
}
} break;
diff --git a/src/dawn_native/ShaderModule.cpp b/src/dawn_native/ShaderModule.cpp
index c0e29e8..42f10c2 100644
--- a/src/dawn_native/ShaderModule.cpp
+++ b/src/dawn_native/ShaderModule.cpp
@@ -596,12 +596,12 @@
const BindGroupLayoutBase* layout) {
// Iterate over all bindings used by this group in the shader, and find the
// corresponding binding in the BindGroupLayout, if it exists.
- for (const auto& it : entryPoint.bindings[group]) {
+ for (const auto& [bindingId, bindingInfo] : entryPoint.bindings[group]) {
DAWN_TRY_CONTEXT(ValidateCompatibilityOfSingleBindingWithLayout(
- device, layout, entryPoint.stage, it.first, it.second),
+ device, layout, entryPoint.stage, bindingId, bindingInfo),
"validating that the entry-point's declaration for [[group(%u), "
"binding(%u)]] matches %s",
- static_cast<uint32_t>(group), static_cast<uint32_t>(it.first),
+ static_cast<uint32_t>(group), static_cast<uint32_t>(bindingId),
layout);
}
@@ -665,15 +665,16 @@
metadata->overridableConstants[identifier] = constant;
if (!c.is_initialized) {
- auto it = metadata->uninitializedOverridableConstants.emplace(
- std::move(identifier));
+ auto [_, inserted] =
+ metadata->uninitializedOverridableConstants.emplace(
+ std::move(identifier));
// The insertion should have taken place
- ASSERT(it.second);
+ ASSERT(inserted);
} else {
- auto it = metadata->initializedOverridableConstants.emplace(
+ auto [_, inserted] = metadata->initializedOverridableConstants.emplace(
std::move(identifier));
// The insertion should have taken place
- ASSERT(it.second);
+ ASSERT(inserted);
}
}
}
@@ -866,14 +867,14 @@
BindingNumber bindingNumber(resource.binding);
BindGroupIndex bindGroupIndex(resource.bind_group);
- const auto& it = metadata->bindings[bindGroupIndex].emplace(
+ const auto& [binding, inserted] = metadata->bindings[bindGroupIndex].emplace(
bindingNumber, ShaderBindingInfo{});
DAWN_INVALID_IF(
- !it.second,
+ !inserted,
"Entry-point has a duplicate binding for (group:%u, binding:%u).",
resource.binding, resource.bind_group);
- ShaderBindingInfo* info = &it.first->second;
+ ShaderBindingInfo* info = &binding->second;
info->bindingType = TintResourceTypeToBindingInfoType(resource.resource_type);
switch (info->bindingType) {
diff --git a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp
index 3001c6c..4515d12 100644
--- a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp
+++ b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp
@@ -90,11 +90,11 @@
std::map<tint::transform::BindingPoint, T, CompareBindingPoint> sorted(map.begin(),
map.end());
- for (auto& entry : sorted) {
+ for (auto& [bindingPoint, value] : sorted) {
output << " ";
- Serialize(output, entry.first);
+ Serialize(output, bindingPoint);
output << "=";
- Serialize(output, entry.second);
+ Serialize(output, value);
}
output << ")";
}
@@ -144,10 +144,7 @@
std::unordered_set<std::string> overriddenConstants;
// Set pipeline overridden values
- for (const auto& pipelineConstant : *pipelineConstantEntries) {
- const std::string& name = pipelineConstant.first;
- double value = pipelineConstant.second;
-
+ for (const auto& [name, value] : *pipelineConstantEntries) {
overriddenConstants.insert(name);
// This is already validated so `name` must exist
@@ -246,9 +243,7 @@
// the Tint AST to make the "bindings" decoration match the offset chosen by
// d3d12::BindGroupLayout so that Tint produces HLSL with the correct registers
// assigned to each interface variable.
- for (const auto& it : groupBindingInfo) {
- BindingNumber binding = it.first;
- auto const& bindingInfo = it.second;
+ for (const auto& [binding, bindingInfo] : groupBindingInfo) {
BindingIndex bindingIndex = bgl->GetBindingIndex(binding);
BindingPoint srcBindingPoint{static_cast<uint32_t>(group),
static_cast<uint32_t>(binding)};
@@ -379,8 +374,8 @@
stream << " hasShaderFloat16Feature=" << hasShaderFloat16Feature;
stream << " defines={";
- for (const auto& it : defineStrings) {
- stream << " <" << it.first << "," << it.second << ">";
+ for (const auto& [name, value] : defineStrings) {
+ stream << " <" << name << "," << value << ">";
}
stream << " }";
@@ -463,15 +458,14 @@
// Build defines for overridable constants
std::vector<std::pair<std::wstring, std::wstring>> defineStrings;
defineStrings.reserve(request.defineStrings.size());
- for (const auto& it : request.defineStrings) {
- defineStrings.emplace_back(UTF8ToWStr(it.first.c_str()),
- UTF8ToWStr(it.second.c_str()));
+ for (const auto& [name, value] : request.defineStrings) {
+ defineStrings.emplace_back(UTF8ToWStr(name.c_str()), UTF8ToWStr(value.c_str()));
}
std::vector<DxcDefine> dxcDefines;
dxcDefines.reserve(defineStrings.size());
- for (const auto& d : defineStrings) {
- dxcDefines.push_back({d.first.c_str(), d.second.c_str()});
+ for (const auto& [name, value] : defineStrings) {
+ dxcDefines.push_back({name.c_str(), value.c_str()});
}
ComPtr<IDxcOperationResult> result;
@@ -584,8 +578,8 @@
std::vector<D3D_SHADER_MACRO> fxcDefines;
if (request.defineStrings.size() > 0) {
fxcDefines.reserve(request.defineStrings.size() + 1);
- for (const auto& d : request.defineStrings) {
- fxcDefines.push_back({d.first.c_str(), d.second.c_str()});
+ for (const auto& [name, value] : request.defineStrings) {
+ fxcDefines.push_back({name.c_str(), value.c_str()});
}
// d3dCompile D3D_SHADER_MACRO* pDefines is a nullptr terminated array
fxcDefines.push_back({nullptr, nullptr});
diff --git a/src/dawn_native/metal/ShaderModuleMTL.mm b/src/dawn_native/metal/ShaderModuleMTL.mm
index 9189cf8..2c2c0f1 100644
--- a/src/dawn_native/metal/ShaderModuleMTL.mm
+++ b/src/dawn_native/metal/ShaderModuleMTL.mm
@@ -68,10 +68,7 @@
for (BindGroupIndex group : IterateBitSet(layout->GetBindGroupLayoutsMask())) {
const BindGroupLayoutBase::BindingMap& bindingMap =
layout->GetBindGroupLayout(group)->GetBindingMap();
- for (const auto& it : bindingMap) {
- BindingNumber bindingNumber = it.first;
- BindingIndex bindingIndex = it.second;
-
+ for (const auto [bindingNumber, bindingIndex] : bindingMap) {
const BindingInfo& bindingInfo =
layout->GetBindGroupLayout(group)->GetBindingInfo(bindingIndex);
diff --git a/src/dawn_native/metal/UtilsMetal.mm b/src/dawn_native/metal/UtilsMetal.mm
index 1a7962a..7fc2429 100644
--- a/src/dawn_native/metal/UtilsMetal.mm
+++ b/src/dawn_native/metal/UtilsMetal.mm
@@ -244,10 +244,7 @@
}
};
- for (const auto& pipelineConstant : programmableStage.constants) {
- const std::string& name = pipelineConstant.first;
- double value = pipelineConstant.second;
-
+ for (const auto& [name, value] : programmableStage.constants) {
overriddenConstants.insert(name);
// This is already validated so `name` must exist
diff --git a/src/dawn_native/opengl/DeviceGL.cpp b/src/dawn_native/opengl/DeviceGL.cpp
index 0240e06..ffaed2b 100644
--- a/src/dawn_native/opengl/DeviceGL.cpp
+++ b/src/dawn_native/opengl/DeviceGL.cpp
@@ -244,8 +244,7 @@
ResultOrError<ExecutionSerial> Device::CheckAndUpdateCompletedSerials() {
ExecutionSerial fenceSerial{0};
while (!mFencesInFlight.empty()) {
- GLsync sync = mFencesInFlight.front().first;
- ExecutionSerial tentativeSerial = mFencesInFlight.front().second;
+ auto [sync, tentativeSerial] = mFencesInFlight.front();
// Fence are added in order, so we can stop searching as soon
// as we see one that's not ready.
diff --git a/src/dawn_native/opengl/ShaderModuleGL.cpp b/src/dawn_native/opengl/ShaderModuleGL.cpp
index dba7b33..a959819 100644
--- a/src/dawn_native/opengl/ShaderModuleGL.cpp
+++ b/src/dawn_native/opengl/ShaderModuleGL.cpp
@@ -96,11 +96,11 @@
DAWN_INVALID_IF(bindGroupIndex >= kMaxBindGroupsTyped,
"Bind group index over limits in the SPIRV");
- const auto& it =
+ const auto& [entry, inserted] =
(*bindings)[bindGroupIndex].emplace(bindingNumber, ShaderBindingInfo{});
- DAWN_INVALID_IF(!it.second, "Shader has duplicate bindings");
+ DAWN_INVALID_IF(!inserted, "Shader has duplicate bindings");
- ShaderBindingInfo* info = &it.first->second;
+ ShaderBindingInfo* info = &entry->second;
info->id = resource.id;
info->base_type_id = resource.base_type_id;
info->bindingType = bindingType;
diff --git a/src/dawn_native/vulkan/BindGroupLayoutVk.cpp b/src/dawn_native/vulkan/BindGroupLayoutVk.cpp
index dc61c03..52038e1 100644
--- a/src/dawn_native/vulkan/BindGroupLayoutVk.cpp
+++ b/src/dawn_native/vulkan/BindGroupLayoutVk.cpp
@@ -95,8 +95,7 @@
ityp::vector<BindingIndex, VkDescriptorSetLayoutBinding> bindings;
bindings.reserve(GetBindingCount());
- for (const auto& it : GetBindingMap()) {
- BindingIndex bindingIndex = it.second;
+ for (const auto& [_, bindingIndex] : GetBindingMap()) {
const BindingInfo& bindingInfo = GetBindingInfo(bindingIndex);
VkDescriptorSetLayoutBinding vkBinding;
diff --git a/src/dawn_native/vulkan/BindGroupVk.cpp b/src/dawn_native/vulkan/BindGroupVk.cpp
index dcfae8f..dc056a7 100644
--- a/src/dawn_native/vulkan/BindGroupVk.cpp
+++ b/src/dawn_native/vulkan/BindGroupVk.cpp
@@ -50,8 +50,7 @@
writeImageInfo(bindingCount);
uint32_t numWrites = 0;
- for (const auto& it : GetLayout()->GetBindingMap()) {
- BindingIndex bindingIndex = it.second;
+ for (const auto [_, bindingIndex] : GetLayout()->GetBindingMap()) {
const BindingInfo& bindingInfo = GetLayout()->GetBindingInfo(bindingIndex);
auto& write = writes[numWrites];
diff --git a/src/dawn_native/vulkan/DescriptorSetAllocator.cpp b/src/dawn_native/vulkan/DescriptorSetAllocator.cpp
index 3f43f67..936a9ba 100644
--- a/src/dawn_native/vulkan/DescriptorSetAllocator.cpp
+++ b/src/dawn_native/vulkan/DescriptorSetAllocator.cpp
@@ -40,10 +40,10 @@
// Compute the total number of descriptors for this layout.
uint32_t totalDescriptorCount = 0;
mPoolSizes.reserve(descriptorCountPerType.size());
- for (const auto& it : descriptorCountPerType) {
- ASSERT(it.second > 0);
- totalDescriptorCount += it.second;
- mPoolSizes.push_back(VkDescriptorPoolSize{it.first, it.second});
+ for (const auto& [type, count] : descriptorCountPerType) {
+ ASSERT(count > 0);
+ totalDescriptorCount += count;
+ mPoolSizes.push_back(VkDescriptorPoolSize{type, count});
}
if (totalDescriptorCount == 0) {
diff --git a/src/dawn_native/vulkan/RenderPassCache.cpp b/src/dawn_native/vulkan/RenderPassCache.cpp
index 2cc815b..120cc0f 100644
--- a/src/dawn_native/vulkan/RenderPassCache.cpp
+++ b/src/dawn_native/vulkan/RenderPassCache.cpp
@@ -86,8 +86,8 @@
RenderPassCache::~RenderPassCache() {
std::lock_guard<std::mutex> lock(mMutex);
- for (auto it : mCache) {
- mDevice->fn.DestroyRenderPass(mDevice->GetVkDevice(), it.second, nullptr);
+ for (auto [_, renderPass] : mCache) {
+ mDevice->fn.DestroyRenderPass(mDevice->GetVkDevice(), renderPass, nullptr);
}
mCache.clear();
diff --git a/src/dawn_native/vulkan/ShaderModuleVk.cpp b/src/dawn_native/vulkan/ShaderModuleVk.cpp
index 45ee439..81f84ab 100644
--- a/src/dawn_native/vulkan/ShaderModuleVk.cpp
+++ b/src/dawn_native/vulkan/ShaderModuleVk.cpp
@@ -36,8 +36,8 @@
ShaderModule::ConcurrentTransformedShaderModuleCache::
~ConcurrentTransformedShaderModuleCache() {
std::lock_guard<std::mutex> lock(mMutex);
- for (const auto& iter : mTransformedShaderModuleCache) {
- mDevice->GetFencedDeleter()->DeleteWhenUnused(iter.second);
+ for (const auto& [_, module] : mTransformedShaderModuleCache) {
+ mDevice->GetFencedDeleter()->DeleteWhenUnused(module);
}
}
diff --git a/src/dawn_node/binding/Converter.h b/src/dawn_node/binding/Converter.h
index 7169cb1..e6b20e8 100644
--- a/src/dawn_node/binding/Converter.h
+++ b/src/dawn_node/binding/Converter.h
@@ -359,8 +359,8 @@
}
auto* els = Allocate<std::remove_const_t<OUT>>(in.size());
size_t i = 0;
- for (auto& it : in) {
- if (!Convert(els[i++], it.first, it.second)) {
+ for (auto& [key, value] : in) {
+ if (!Convert(els[i++], key, value)) {
return false;
}
}
diff --git a/src/dawn_node/utils/Debug.h b/src/dawn_node/utils/Debug.h
index 3873540..3636df0 100644
--- a/src/dawn_node/utils/Debug.h
+++ b/src/dawn_node/utils/Debug.h
@@ -71,14 +71,14 @@
std::ostream& Write(std::ostream& out, const std::unordered_map<K, V>& value) {
out << "{";
bool first = true;
- for (auto it : value) {
+ for (auto& [key, value] : value) {
if (!first) {
out << ", ";
}
first = false;
- Write(out, it.first);
+ Write(out, key);
out << ": ";
- Write(out, it.second);
+ Write(out, value);
}
return out << "}";
}
diff --git a/src/dawn_wire/client/RequestTracker.h b/src/dawn_wire/client/RequestTracker.h
index 7ce2d00..56691c2 100644
--- a/src/dawn_wire/client/RequestTracker.h
+++ b/src/dawn_wire/client/RequestTracker.h
@@ -59,16 +59,16 @@
// Move mRequests to a local variable so that further reentrant modifications of
// mRequests don't invalidate the iterators.
auto allRequests = std::move(mRequests);
- for (auto& it : allRequests) {
- closeFunc(&it.second);
+ for (auto& [_, request] : allRequests) {
+ closeFunc(&request);
}
}
}
template <typename F>
void ForAll(F&& f) {
- for (auto& it : mRequests) {
- f(&it.second);
+ for (auto& [_, request] : mRequests) {
+ f(&request);
}
}
diff --git a/src/dawn_wire/server/Server.cpp b/src/dawn_wire/server/Server.cpp
index 6fea9fc..13ac756 100644
--- a/src/dawn_wire/server/Server.cpp
+++ b/src/dawn_wire/server/Server.cpp
@@ -191,8 +191,8 @@
}
bool TrackDeviceChild(DeviceInfo* info, ObjectType type, ObjectId id) {
- auto it = info->childObjectTypesAndIds.insert(PackObjectTypeAndId(type, id));
- if (!it.second) {
+ auto [_, inserted] = info->childObjectTypesAndIds.insert(PackObjectTypeAndId(type, id));
+ if (!inserted) {
// An object of this type and id already exists.
return false;
}
diff --git a/src/tests/MockCallback.h b/src/tests/MockCallback.h
index c3dfb4a..4acb904 100644
--- a/src/tests/MockCallback.h
+++ b/src/tests/MockCallback.h
@@ -53,9 +53,9 @@
// remove from this set even if a callback should only be called once so that
// repeated calls to the callback still forward the userdata correctly.
// Userdata will be destroyed when the mock is destroyed.
- auto it = mUserdatas.insert(std::move(mockAndUserdata));
- ASSERT(it.second);
- return it.first->get();
+ auto [result, inserted] = mUserdatas.insert(std::move(mockAndUserdata));
+ ASSERT(inserted);
+ return result->get();
}
private:
diff --git a/src/tests/end2end/ColorStateTests.cpp b/src/tests/end2end/ColorStateTests.cpp
index 1fd3845..4cd13f9 100644
--- a/src/tests/end2end/ColorStateTests.cpp
+++ b/src/tests/end2end/ColorStateTests.cpp
@@ -157,8 +157,8 @@
SetupSingleSourcePipelines(descriptor);
- for (const auto& test : tests) {
- DoSingleSourceTest(base, {test.first}, test.second);
+ for (const auto& [triangleColor, expectedColor] : tests) {
+ DoSingleSourceTest(base, {triangleColor}, expectedColor);
}
}
@@ -190,8 +190,8 @@
SetupSingleSourcePipelines(descriptor);
- for (const auto& test : tests) {
- DoSingleSourceTest(base, test.first, test.second);
+ for (const auto& [triangles, expectedColor] : tests) {
+ DoSingleSourceTest(base, triangles, expectedColor);
}
}
diff --git a/src/tests/end2end/DepthStencilStateTests.cpp b/src/tests/end2end/DepthStencilStateTests.cpp
index 73e9aad..bd4672a 100644
--- a/src/tests/end2end/DepthStencilStateTests.cpp
+++ b/src/tests/end2end/DepthStencilStateTests.cpp
@@ -811,9 +811,7 @@
{stencilEqualKeepState, RGBA8::kGreen, 0.f, 0x0, wgpu::FrontFace::CCW, false}};
// Since the stencil reference is not inherited, second draw won't pass the stencil test
- std::pair<RGBA8, RGBA8> expectation = {RGBA8::kZero, RGBA8::kZero};
-
- DoTest(testParams, expectation.first, expectation.second, true);
+ DoTest(testParams, RGBA8::kZero, RGBA8::kZero, true);
}
// Test that stencil reference is initialized as zero for new render pass
@@ -826,9 +824,7 @@
{stencilEqualKeepState, RGBA8::kBlue, 0.f, 0x0, wgpu::FrontFace::CCW, true}};
// The third draw should pass the stencil test since the second pass set it to default zero
- std::pair<RGBA8, RGBA8> expectation = {RGBA8::kBlue, RGBA8::kBlue};
-
- DoTest(testParams, expectation.first, expectation.second, true);
+ DoTest(testParams, RGBA8::kBlue, RGBA8::kBlue, true);
}
}