From af0c267d965f6279ba67a73d552025062c05f25c Mon Sep 17 00:00:00 2001 From: scribam Date: Sat, 13 Mar 2021 13:47:38 +0100 Subject: [PATCH] clang-tidy: run modernize-use-emplace --- core/hw/naomi/naomi_cart.cpp | 4 ++-- core/network/miniupnp.cpp | 2 +- core/rend/gui_util.cpp | 4 ++-- core/rend/vulkan/oit/oit_buffer.h | 6 +++--- core/rend/vulkan/oit/oit_drawer.h | 2 +- core/rend/vulkan/oit/oit_pipeline.h | 22 +++++++++++----------- core/rend/vulkan/pipeline.h | 16 ++++++++-------- core/rend/vulkan/quad.cpp | 3 +-- 8 files changed, 29 insertions(+), 30 deletions(-) diff --git a/core/hw/naomi/naomi_cart.cpp b/core/hw/naomi/naomi_cart.cpp index 638185a70..d0070864e 100644 --- a/core/hw/naomi/naomi_cart.cpp +++ b/core/hw/naomi/naomi_cart.cpp @@ -443,7 +443,7 @@ void naomi_cart_LoadRom(const char* file) u32 addr, sz; if (sscanf(line, "\"%[^\"]\",%x,%x", filename, &addr, &sz) == 3) { - files.push_back(filename); + files.emplace_back(filename); fstart.push_back(addr); fsize.push_back(sz); romSize = std::max(romSize, (addr + sz)); @@ -465,7 +465,7 @@ void naomi_cart_LoadRom(const char* file) std::fseek(fp, 0, SEEK_END); u32 file_size = (u32)std::ftell(fp); std::fclose(fp); - files.push_back(file); + files.emplace_back(file); fstart.push_back(0); fsize.push_back(file_size); romSize = file_size; diff --git a/core/network/miniupnp.cpp b/core/network/miniupnp.cpp index dc2786ddf..e046a02c0 100644 --- a/core/network/miniupnp.cpp +++ b/core/network/miniupnp.cpp @@ -76,6 +76,6 @@ bool MiniUPnP::AddPortMapping(int port, bool tcp) INFO_LOG(MODEM, "Port %d redirection failed: error %d", port, error); return false; } - mappedPorts.push_back(std::make_pair(portStr, tcp)); + mappedPorts.emplace_back(portStr, tcp); return true; } diff --git a/core/rend/gui_util.cpp b/core/rend/gui_util.cpp index eefaca878..7ea5f1022 100644 --- a/core/rend/gui_util.cpp +++ b/core/rend/gui_util.cpp @@ -134,7 +134,7 @@ void select_directory_popup(const char *prompt, float scaling, StringCallback ca if (dir == NULL) { error_message = "Cannot read " + select_current_directory; - select_subfolders.push_back(".."); + select_subfolders.emplace_back(".."); } else { @@ -183,7 +183,7 @@ void select_directory_popup(const char *prompt, float scaling, StringCallback ca flycast::closedir(dir); #if defined(_WIN32) || defined(__ANDROID__) if (!dotdot_seen) - select_subfolders.push_back(".."); + select_subfolders.emplace_back(".."); #endif } } diff --git a/core/rend/vulkan/oit/oit_buffer.h b/core/rend/vulkan/oit/oit_buffer.h index b76c72e19..c8a9a20e9 100644 --- a/core/rend/vulkan/oit/oit_buffer.h +++ b/core/rend/vulkan/oit/oit_buffer.h @@ -76,11 +76,11 @@ public: vk::DescriptorSetAllocateInfo(context->GetDescriptorPool(), 1, &descSetLayout.get())).front()); std::vector writeDescriptorSets; vk::DescriptorBufferInfo pixelBufferInfo(*pixelBuffer->buffer, 0, VK_WHOLE_SIZE); - writeDescriptorSets.push_back(vk::WriteDescriptorSet(*descSet, 0, 0, 1, vk::DescriptorType::eStorageBuffer, nullptr, &pixelBufferInfo, nullptr)); + writeDescriptorSets.emplace_back(*descSet, 0, 0, 1, vk::DescriptorType::eStorageBuffer, nullptr, &pixelBufferInfo, nullptr); vk::DescriptorBufferInfo pixelCounterBufferInfo(*pixelCounter->buffer, 0, 4); - writeDescriptorSets.push_back(vk::WriteDescriptorSet(*descSet, 1, 0, 1, vk::DescriptorType::eStorageBuffer, nullptr, &pixelCounterBufferInfo, nullptr)); + writeDescriptorSets.emplace_back(*descSet, 1, 0, 1, vk::DescriptorType::eStorageBuffer, nullptr, &pixelCounterBufferInfo, nullptr); vk::DescriptorImageInfo pointerImageInfo(vk::Sampler(), abufferPointerAttachment->GetImageView(), vk::ImageLayout::eGeneral); - writeDescriptorSets.push_back(vk::WriteDescriptorSet(*descSet, 2, 0, 1, vk::DescriptorType::eStorageImage, &pointerImageInfo, nullptr, nullptr)); + writeDescriptorSets.emplace_back(*descSet, 2, 0, 1, vk::DescriptorType::eStorageImage, &pointerImageInfo, nullptr, nullptr); context->GetDevice().updateDescriptorSets(writeDescriptorSets, nullptr); } diff --git a/core/rend/vulkan/oit/oit_drawer.h b/core/rend/vulkan/oit/oit_drawer.h index 33fe6f00d..52ed9dd00 100644 --- a/core/rend/vulkan/oit/oit_drawer.h +++ b/core/rend/vulkan/oit/oit_drawer.h @@ -57,7 +57,7 @@ protected: else while (descriptorSets.size() < GetContext()->GetSwapChainSize()) { - descriptorSets.push_back(OITDescriptorSets()); + descriptorSets.emplace_back(); descriptorSets.back().Init(samplerManager, pipelineManager->GetPipelineLayout(), pipelineManager->GetPerFrameDSLayout(), diff --git a/core/rend/vulkan/oit/oit_pipeline.h b/core/rend/vulkan/oit/oit_pipeline.h index ca01d7951..7296fc75d 100644 --- a/core/rend/vulkan/oit/oit_pipeline.h +++ b/core/rend/vulkan/oit/oit_pipeline.h @@ -100,12 +100,12 @@ public: vk::DescriptorSet perFrameDescSet = *perFrameDescSetsInFlight.back(); std::vector bufferInfos; - bufferInfos.push_back(vk::DescriptorBufferInfo(buffer, vertexUniformOffset, sizeof(VertexShaderUniforms))); - bufferInfos.push_back(vk::DescriptorBufferInfo(buffer, fragmentUniformOffset, sizeof(FragmentShaderUniforms))); + bufferInfos.emplace_back(buffer, vertexUniformOffset, sizeof(VertexShaderUniforms)); + bufferInfos.emplace_back(buffer, fragmentUniformOffset, sizeof(FragmentShaderUniforms)); std::vector writeDescriptorSets; - writeDescriptorSets.push_back(vk::WriteDescriptorSet(perFrameDescSet, 0, 0, 1, vk::DescriptorType::eUniformBuffer, nullptr, &bufferInfos[0], nullptr)); - writeDescriptorSets.push_back(vk::WriteDescriptorSet(perFrameDescSet, 1, 0, 1, vk::DescriptorType::eUniformBuffer, nullptr, &bufferInfos[1], nullptr)); + writeDescriptorSets.emplace_back(perFrameDescSet, 0, 0, 1, vk::DescriptorType::eUniformBuffer, nullptr, &bufferInfos[0], nullptr); + writeDescriptorSets.emplace_back(perFrameDescSet, 1, 0, 1, vk::DescriptorType::eUniformBuffer, nullptr, &bufferInfos[1], nullptr); if (fogImageView) { TSP fogTsp = {}; @@ -115,7 +115,7 @@ public: vk::Sampler fogSampler = samplerManager->GetSampler(fogTsp); static vk::DescriptorImageInfo imageInfo; imageInfo = { fogSampler, fogImageView, vk::ImageLayout::eShaderReadOnlyOptimal }; - writeDescriptorSets.push_back(vk::WriteDescriptorSet(perFrameDescSet, 2, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo, nullptr, nullptr)); + writeDescriptorSets.emplace_back(perFrameDescSet, 2, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo, nullptr, nullptr); } if (paletteImageView) { @@ -126,18 +126,18 @@ public: vk::Sampler palSampler = samplerManager->GetSampler(palTsp); static vk::DescriptorImageInfo imageInfo; imageInfo = { palSampler, paletteImageView, vk::ImageLayout::eShaderReadOnlyOptimal }; - writeDescriptorSets.push_back(vk::WriteDescriptorSet(perFrameDescSet, 6, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo, nullptr, nullptr)); + writeDescriptorSets.emplace_back(perFrameDescSet, 6, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo, nullptr, nullptr); } if (polyParamsSize > 0) { static vk::DescriptorBufferInfo polyParamsBufferInfo; polyParamsBufferInfo = vk::DescriptorBufferInfo(buffer, polyParamsOffset, polyParamsSize); - writeDescriptorSets.push_back(vk::WriteDescriptorSet(perFrameDescSet, 3, 0, 1, vk::DescriptorType::eStorageBuffer, nullptr, &polyParamsBufferInfo, nullptr)); + writeDescriptorSets.emplace_back(perFrameDescSet, 3, 0, 1, vk::DescriptorType::eStorageBuffer, nullptr, &polyParamsBufferInfo, nullptr); } vk::DescriptorImageInfo stencilImageInfo(vk::Sampler(), stencilImageView, vk::ImageLayout::eDepthStencilReadOnlyOptimal); - writeDescriptorSets.push_back(vk::WriteDescriptorSet(perFrameDescSet, 4, 0, 1, vk::DescriptorType::eInputAttachment, &stencilImageInfo, nullptr, nullptr)); + writeDescriptorSets.emplace_back(perFrameDescSet, 4, 0, 1, vk::DescriptorType::eInputAttachment, &stencilImageInfo, nullptr, nullptr); vk::DescriptorImageInfo depthImageInfo(vk::Sampler(), depthImageView, vk::ImageLayout::eDepthStencilReadOnlyOptimal); - writeDescriptorSets.push_back(vk::WriteDescriptorSet(perFrameDescSet, 5, 0, 1, vk::DescriptorType::eInputAttachment, &depthImageInfo, nullptr, nullptr)); + writeDescriptorSets.emplace_back(perFrameDescSet, 5, 0, 1, vk::DescriptorType::eInputAttachment, &depthImageInfo, nullptr, nullptr); GetContext()->GetDevice().updateDescriptorSets(writeDescriptorSets, nullptr); } @@ -172,14 +172,14 @@ public: vk::DescriptorImageInfo imageInfo0(samplerManager->GetSampler(tsp0), texture->GetReadOnlyImageView(), vk::ImageLayout::eShaderReadOnlyOptimal); std::vector writeDescriptorSets; - writeDescriptorSets.push_back(vk::WriteDescriptorSet(*perPolyDescSets.back(), 0, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo0, nullptr, nullptr)); + writeDescriptorSets.emplace_back(*perPolyDescSets.back(), 0, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo0, nullptr, nullptr); if (textureId1 != (u64)-1) { Texture *texture1 = reinterpret_cast(textureId1); vk::DescriptorImageInfo imageInfo1(samplerManager->GetSampler(tsp1), texture1->GetReadOnlyImageView(), vk::ImageLayout::eShaderReadOnlyOptimal); - writeDescriptorSets.push_back(vk::WriteDescriptorSet(*perPolyDescSets.back(), 1, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo1, nullptr, nullptr)); + writeDescriptorSets.emplace_back(*perPolyDescSets.back(), 1, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo1, nullptr, nullptr); } GetContext()->GetDevice().updateDescriptorSets(writeDescriptorSets, nullptr); perPolyDescSetsInFlight[index] = std::move(perPolyDescSets.back()); diff --git a/core/rend/vulkan/pipeline.h b/core/rend/vulkan/pipeline.h index 71e4c590d..96e9914ab 100644 --- a/core/rend/vulkan/pipeline.h +++ b/core/rend/vulkan/pipeline.h @@ -54,12 +54,12 @@ public: vk::DescriptorSet perFrameDescSet = *perFrameDescSetsInFlight.back(); std::vector bufferInfos; - bufferInfos.push_back(vk::DescriptorBufferInfo(buffer, vertexUniformOffset, sizeof(VertexShaderUniforms))); - bufferInfos.push_back(vk::DescriptorBufferInfo(buffer, fragmentUniformOffset, sizeof(FragmentShaderUniforms))); + bufferInfos.emplace_back(buffer, vertexUniformOffset, sizeof(VertexShaderUniforms)); + bufferInfos.emplace_back(buffer, fragmentUniformOffset, sizeof(FragmentShaderUniforms)); std::vector writeDescriptorSets; - writeDescriptorSets.push_back(vk::WriteDescriptorSet(perFrameDescSet, 0, 0, 1, vk::DescriptorType::eUniformBuffer, nullptr, &bufferInfos[0], nullptr)); - writeDescriptorSets.push_back(vk::WriteDescriptorSet(perFrameDescSet, 1, 0, 1, vk::DescriptorType::eUniformBuffer, nullptr, &bufferInfos[1], nullptr)); + writeDescriptorSets.emplace_back(perFrameDescSet, 0, 0, 1, vk::DescriptorType::eUniformBuffer, nullptr, &bufferInfos[0], nullptr); + writeDescriptorSets.emplace_back(perFrameDescSet, 1, 0, 1, vk::DescriptorType::eUniformBuffer, nullptr, &bufferInfos[1], nullptr); if (fogImageView) { TSP fogTsp = {}; @@ -69,7 +69,7 @@ public: vk::Sampler fogSampler = samplerManager->GetSampler(fogTsp); static vk::DescriptorImageInfo imageInfo; imageInfo = { fogSampler, fogImageView, vk::ImageLayout::eShaderReadOnlyOptimal }; - writeDescriptorSets.push_back(vk::WriteDescriptorSet(perFrameDescSet, 2, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo, nullptr, nullptr)); + writeDescriptorSets.emplace_back(perFrameDescSet, 2, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo, nullptr, nullptr); } if (paletteImageView) { @@ -80,7 +80,7 @@ public: vk::Sampler palSampler = samplerManager->GetSampler(palTsp); static vk::DescriptorImageInfo imageInfo; imageInfo = { palSampler, paletteImageView, vk::ImageLayout::eShaderReadOnlyOptimal }; - writeDescriptorSets.push_back(vk::WriteDescriptorSet(perFrameDescSet, 3, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo, nullptr, nullptr)); + writeDescriptorSets.emplace_back(perFrameDescSet, 3, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo, nullptr, nullptr); } GetContext()->GetDevice().updateDescriptorSets(writeDescriptorSets, nullptr); } @@ -102,7 +102,7 @@ public: vk::DescriptorImageInfo imageInfo(samplerManager->GetSampler(tsp), texture->GetReadOnlyImageView(), vk::ImageLayout::eShaderReadOnlyOptimal); std::vector writeDescriptorSets; - writeDescriptorSets.push_back(vk::WriteDescriptorSet(*perPolyDescSets.back(), 0, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo, nullptr, nullptr)); + writeDescriptorSets.emplace_back(*perPolyDescSets.back(), 0, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo, nullptr, nullptr); GetContext()->GetDevice().updateDescriptorSets(writeDescriptorSets, nullptr); inFlight[index] = std::move(perPolyDescSets.back()); @@ -365,7 +365,7 @@ public: } vk::DescriptorImageInfo imageInfo(*sampler, imageView, vk::ImageLayout::eShaderReadOnlyOptimal); std::vector writeDescriptorSets; - writeDescriptorSets.push_back(vk::WriteDescriptorSet(*descriptorSet, 0, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo, nullptr, nullptr)); + writeDescriptorSets.emplace_back(*descriptorSet, 0, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo, nullptr, nullptr); GetContext()->GetDevice().updateDescriptorSets(writeDescriptorSets, nullptr); } diff --git a/core/rend/vulkan/quad.cpp b/core/rend/vulkan/quad.cpp index 2fc375780..eb1bc87f0 100644 --- a/core/rend/vulkan/quad.cpp +++ b/core/rend/vulkan/quad.cpp @@ -199,8 +199,7 @@ void QuadDrawer::Draw(vk::CommandBuffer commandBuffer, vk::ImageView imageView, } vk::DescriptorImageInfo imageInfo(nearestFilter ? pipeline->GetNearestSampler() : pipeline->GetLinearSampler(), imageView, vk::ImageLayout::eShaderReadOnlyOptimal); std::vector writeDescriptorSets; - writeDescriptorSets.push_back( - vk::WriteDescriptorSet(*descSet, 0, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo, nullptr, nullptr)); + writeDescriptorSets.emplace_back(*descSet, 0, 0, 1, vk::DescriptorType::eCombinedImageSampler, &imageInfo, nullptr, nullptr); context->GetDevice().updateDescriptorSets(writeDescriptorSets, nullptr); commandBuffer.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, pipeline->GetPipelineLayout(), 0, 1, &descSet.get(), 0, nullptr);