Use C++17 structure bindings instead of some std::tie

Not all std::tie can be replaced because structured binding introduces
references names and cannot bind member variables.

Bug: dawn:824
Change-Id: Ie2b45834aac72fb063d4aaea5949a53457bc73c9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75068
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:
Corentin Wallez 2022-01-06 09:14:17 +00:00 committed by Dawn LUCI CQ
parent a4357a7619
commit 1c49d1b43b
3 changed files with 16 additions and 51 deletions

View File

@ -94,9 +94,7 @@ namespace dawn_wire { namespace server {
//* Dawn native that makes all child objects internally null if their
//* Device is destroyed.
while (data->info->childObjectTypesAndIds.size() > 0) {
ObjectType childObjectType;
ObjectId childObjectId;
std::tie(childObjectType, childObjectId) = UnpackObjectTypeAndId(
auto [childObjectType, childObjectId] = UnpackObjectTypeAndId(
*data->info->childObjectTypesAndIds.begin());
if (!DoDestroyObject(childObjectType, childObjectId)) {
return false;

View File

@ -94,9 +94,7 @@ class GpuMemorySyncTests : public DawnTest {
TEST_P(GpuMemorySyncTests, ComputePass) {
// Create pipeline, bind group, and buffer for compute pass.
wgpu::Buffer buffer = CreateBuffer();
wgpu::ComputePipeline compute;
wgpu::BindGroup bindGroup;
std::tie(compute, bindGroup) = CreatePipelineAndBindGroupForCompute(buffer);
auto [compute, bindGroup] = CreatePipelineAndBindGroupForCompute(buffer);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
// Iterate the read-add-write operations in compute pass a few times.
@ -126,10 +124,7 @@ TEST_P(GpuMemorySyncTests, RenderPass) {
// Create pipeline, bind group, and buffer for render pass.
wgpu::Buffer buffer = CreateBuffer();
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);
wgpu::RenderPipeline render;
wgpu::BindGroup bindGroup;
std::tie(render, bindGroup) =
CreatePipelineAndBindGroupForRender(buffer, renderPass.colorFormat);
auto [render, bindGroup] = CreatePipelineAndBindGroupForRender(buffer, renderPass.colorFormat);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
// Iterate the read-add-write operations in render pass a few times.
@ -155,14 +150,9 @@ TEST_P(GpuMemorySyncTests, RenderPassToComputePass) {
// Create pipeline, bind group, and buffer for render pass and compute pass.
wgpu::Buffer buffer = CreateBuffer();
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);
wgpu::RenderPipeline render;
wgpu::BindGroup bindGroup0;
std::tie(render, bindGroup0) =
CreatePipelineAndBindGroupForRender(buffer, renderPass.colorFormat);
wgpu::ComputePipeline compute;
wgpu::BindGroup bindGroup1;
std::tie(compute, bindGroup1) = CreatePipelineAndBindGroupForCompute(buffer);
auto [render, bindGroup0] = CreatePipelineAndBindGroupForRender(buffer, renderPass.colorFormat);
auto [compute, bindGroup1] = CreatePipelineAndBindGroupForCompute(buffer);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
@ -192,15 +182,10 @@ TEST_P(GpuMemorySyncTests, RenderPassToComputePass) {
TEST_P(GpuMemorySyncTests, ComputePassToRenderPass) {
// Create pipeline, bind group, and buffer for compute pass and render pass.
wgpu::Buffer buffer = CreateBuffer();
wgpu::ComputePipeline compute;
wgpu::BindGroup bindGroup1;
std::tie(compute, bindGroup1) = CreatePipelineAndBindGroupForCompute(buffer);
auto [compute, bindGroup1] = CreatePipelineAndBindGroupForCompute(buffer);
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);
wgpu::RenderPipeline render;
wgpu::BindGroup bindGroup0;
std::tie(render, bindGroup0) =
CreatePipelineAndBindGroupForRender(buffer, renderPass.colorFormat);
auto [render, bindGroup0] = CreatePipelineAndBindGroupForRender(buffer, renderPass.colorFormat);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
@ -300,12 +285,8 @@ TEST_P(StorageToUniformSyncTests, ReadAfterWriteWithSameCommandBuffer) {
// Create pipeline, bind group, and buffer for compute pass and render pass.
CreateBuffer();
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);
wgpu::ComputePipeline compute;
wgpu::BindGroup computeBindGroup;
std::tie(compute, computeBindGroup) = CreatePipelineAndBindGroupForCompute();
wgpu::RenderPipeline render;
wgpu::BindGroup renderBindGroup;
std::tie(render, renderBindGroup) = CreatePipelineAndBindGroupForRender(renderPass.colorFormat);
auto [compute, computeBindGroup] = CreatePipelineAndBindGroupForCompute();
auto [render, renderBindGroup] = CreatePipelineAndBindGroupForRender(renderPass.colorFormat);
// Write data into a storage buffer in compute pass.
wgpu::CommandEncoder encoder0 = device.CreateCommandEncoder();
@ -336,12 +317,8 @@ TEST_P(StorageToUniformSyncTests, ReadAfterWriteWithDifferentCommandBuffers) {
// Create pipeline, bind group, and buffer for compute pass and render pass.
CreateBuffer();
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);
wgpu::ComputePipeline compute;
wgpu::BindGroup computeBindGroup;
std::tie(compute, computeBindGroup) = CreatePipelineAndBindGroupForCompute();
wgpu::RenderPipeline render;
wgpu::BindGroup renderBindGroup;
std::tie(render, renderBindGroup) = CreatePipelineAndBindGroupForRender(renderPass.colorFormat);
auto [compute, computeBindGroup] = CreatePipelineAndBindGroupForCompute();
auto [render, renderBindGroup] = CreatePipelineAndBindGroupForRender(renderPass.colorFormat);
// Write data into a storage buffer in compute pass.
wgpu::CommandBuffer cb[2];
@ -375,12 +352,8 @@ TEST_P(StorageToUniformSyncTests, ReadAfterWriteWithDifferentQueueSubmits) {
// Create pipeline, bind group, and buffer for compute pass and render pass.
CreateBuffer();
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);
wgpu::ComputePipeline compute;
wgpu::BindGroup computeBindGroup;
std::tie(compute, computeBindGroup) = CreatePipelineAndBindGroupForCompute();
wgpu::RenderPipeline render;
wgpu::BindGroup renderBindGroup;
std::tie(render, renderBindGroup) = CreatePipelineAndBindGroupForRender(renderPass.colorFormat);
auto [compute, computeBindGroup] = CreatePipelineAndBindGroupForCompute();
auto [render, renderBindGroup] = CreatePipelineAndBindGroupForRender(renderPass.colorFormat);
// Write data into a storage buffer in compute pass.
wgpu::CommandBuffer cb[2];

View File

@ -1916,9 +1916,7 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
// Test it is valid to set bind groups before setting the pipeline.
TEST_F(SetBindGroupPersistenceValidationTest, BindGroupBeforePipeline) {
std::vector<wgpu::BindGroupLayout> bindGroupLayouts;
wgpu::RenderPipeline pipeline;
std::tie(bindGroupLayouts, pipeline) = SetUpLayoutsAndPipeline({{
auto [bindGroupLayouts, pipeline] = SetUpLayoutsAndPipeline({{
{{
wgpu::BufferBindingType::Uniform,
wgpu::BufferBindingType::Uniform,
@ -1957,9 +1955,7 @@ TEST_F(SetBindGroupPersistenceValidationTest, BindGroupBeforePipeline) {
// Test that it is valid to draw with bind groups that are not "inherited". They persist
// after a pipeline change.
TEST_F(SetBindGroupPersistenceValidationTest, NotVulkanInheritance) {
std::vector<wgpu::BindGroupLayout> bindGroupLayoutsA;
wgpu::RenderPipeline pipelineA;
std::tie(bindGroupLayoutsA, pipelineA) = SetUpLayoutsAndPipeline({{
auto [bindGroupLayoutsA, pipelineA] = SetUpLayoutsAndPipeline({{
{{
wgpu::BufferBindingType::Uniform,
wgpu::BufferBindingType::Storage,
@ -1970,9 +1966,7 @@ TEST_F(SetBindGroupPersistenceValidationTest, NotVulkanInheritance) {
}},
}});
std::vector<wgpu::BindGroupLayout> bindGroupLayoutsB;
wgpu::RenderPipeline pipelineB;
std::tie(bindGroupLayoutsB, pipelineB) = SetUpLayoutsAndPipeline({{
auto [bindGroupLayoutsB, pipelineB] = SetUpLayoutsAndPipeline({{
{{
wgpu::BufferBindingType::Storage,
wgpu::BufferBindingType::Uniform,