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>
This commit is contained in:
parent
1c49d1b43b
commit
5984d8d1a8
|
@ -37,8 +37,8 @@ class ConcurrentCache : public NonMovable {
|
|||
|
||||
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) {
|
||||
|
|
|
@ -46,8 +46,8 @@ namespace dawn_native {
|
|||
allPendingTasks.swap(mPendingTasks);
|
||||
}
|
||||
|
||||
for (auto& keyValue : allPendingTasks) {
|
||||
keyValue.second->waitableEvent->Wait();
|
||||
for (auto& [_, task] : allPendingTasks) {
|
||||
task->waitableEvent->Wait();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -382,8 +382,8 @@ namespace dawn_native {
|
|||
}
|
||||
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 @@ namespace dawn_native {
|
|||
|
||||
// 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);
|
||||
|
||||
const BindingInfo& info = mBindingInfo[it.second];
|
||||
for (const auto [id, index] : mBindingMap) {
|
||||
recorder.Record(id, index);
|
||||
|
||||
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,
|
||||
|
|
|
@ -748,23 +748,23 @@ namespace dawn_native {
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -256,9 +256,9 @@ namespace dawn_native {
|
|||
{"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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -139,22 +139,21 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -230,11 +230,10 @@ namespace dawn_native {
|
|||
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 =
|
||||
|
|
|
@ -154,14 +154,14 @@ namespace dawn_native {
|
|||
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) {
|
||||
|
|
|
@ -235,8 +235,8 @@ namespace dawn_native {
|
|||
-> 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 @@ namespace dawn_native {
|
|||
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 @@ namespace dawn_native {
|
|||
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,9 +73,9 @@ namespace dawn_native {
|
|||
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;
|
||||
|
|
|
@ -596,12 +596,12 @@ namespace dawn_native {
|
|||
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 @@ namespace dawn_native {
|
|||
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 @@ namespace dawn_native {
|
|||
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) {
|
||||
|
|
|
@ -90,11 +90,11 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
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 @@ namespace dawn_native { namespace d3d12 {
|
|||
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 @@ namespace dawn_native { namespace d3d12 {
|
|||
// 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 @@ namespace dawn_native { namespace d3d12 {
|
|||
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 @@ namespace dawn_native { namespace d3d12 {
|
|||
// 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 @@ namespace dawn_native { namespace d3d12 {
|
|||
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});
|
||||
|
|
|
@ -68,10 +68,7 @@ namespace dawn_native { namespace metal {
|
|||
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);
|
||||
|
||||
|
|
|
@ -244,10 +244,7 @@ namespace dawn_native { namespace metal {
|
|||
}
|
||||
};
|
||||
|
||||
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
|
||||
|
|
|
@ -244,8 +244,7 @@ namespace dawn_native { namespace opengl {
|
|||
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.
|
||||
|
|
|
@ -96,11 +96,11 @@ namespace dawn_native { namespace opengl {
|
|||
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;
|
||||
|
|
|
@ -95,8 +95,7 @@ namespace dawn_native { namespace vulkan {
|
|||
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;
|
||||
|
|
|
@ -50,8 +50,7 @@ namespace dawn_native { namespace vulkan {
|
|||
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];
|
||||
|
|
|
@ -40,10 +40,10 @@ namespace dawn_native { namespace vulkan {
|
|||
// 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) {
|
||||
|
|
|
@ -86,8 +86,8 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
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();
|
||||
|
|
|
@ -36,8 +36,8 @@ namespace dawn_native { namespace vulkan {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -359,8 +359,8 @@ namespace wgpu { namespace binding {
|
|||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,14 +71,14 @@ namespace wgpu { namespace utils {
|
|||
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 << "}";
|
||||
}
|
||||
|
|
|
@ -59,16 +59,16 @@ namespace dawn_wire { namespace client {
|
|||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -191,8 +191,8 @@ namespace dawn_wire { namespace server {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -53,9 +53,9 @@ namespace testing {
|
|||
// 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:
|
||||
|
|
|
@ -157,8 +157,8 @@ class ColorStateTest : public DawnTest {
|
|||
|
||||
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 @@ class ColorStateTest : public DawnTest {
|
|||
|
||||
SetupSingleSourcePipelines(descriptor);
|
||||
|
||||
for (const auto& test : tests) {
|
||||
DoSingleSourceTest(base, test.first, test.second);
|
||||
for (const auto& [triangles, expectedColor] : tests) {
|
||||
DoSingleSourceTest(base, triangles, expectedColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -811,9 +811,7 @@ TEST_P(DepthStencilStateTest, StencilReferenceInitialized) {
|
|||
{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 @@ TEST_P(DepthStencilStateTest, StencilReferenceInitialized) {
|
|||
{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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue