From e15ec2705c20ead2257ea7e7f85619a16a7c7de8 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 15 Apr 2020 21:50:06 -0400 Subject: track: Eliminate redundant copies Two variables can be references, while two others can be std::moved. Makes for 4 less atomic reference count increments and decrements. --- src/video_core/shader/track.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/video_core/shader/track.cpp b/src/video_core/shader/track.cpp index 10739b37d..ffd1d5504 100644 --- a/src/video_core/shader/track.cpp +++ b/src/video_core/shader/track.cpp @@ -75,12 +75,13 @@ std::tuple ShaderIR::TrackBindlessSampler(Node tracked, cons s64 cursor) { if (const auto cbuf = std::get_if(&*tracked)) { // Constant buffer found, test if it's an immediate - const auto offset = cbuf->GetOffset(); + const auto& offset = cbuf->GetOffset(); if (const auto immediate = std::get_if(&*offset)) { auto track = MakeTrackSampler(cbuf->GetIndex(), immediate->GetValue()); return {tracked, track}; - } else if (const auto operation = std::get_if(&*offset)) { + } + if (const auto operation = std::get_if(&*offset)) { const u32 bound_buffer = registry.GetBoundBuffer(); if (bound_buffer != cbuf->GetIndex()) { return {}; @@ -93,12 +94,12 @@ std::tuple ShaderIR::TrackBindlessSampler(Node tracked, cons const auto offset_inm = std::get_if(&*base_offset); const auto& gpu_driver = registry.AccessGuestDriverProfile(); const u32 bindless_cv = NewCustomVariable(); - const Node op = + Node op = Operation(OperationCode::UDiv, gpr, Immediate(gpu_driver.GetTextureHandlerSize())); const Node cv_node = GetCustomVariable(bindless_cv); Node amend_op = Operation(OperationCode::Assign, cv_node, std::move(op)); - const std::size_t amend_index = DeclareAmend(amend_op); + const std::size_t amend_index = DeclareAmend(std::move(amend_op)); AmendNodeCv(amend_index, code[cursor]); // TODO Implement Bindless Index custom variable auto track = MakeTrackSampler(cbuf->GetIndex(), @@ -141,7 +142,7 @@ std::tuple ShaderIR::TrackCbuf(Node tracked, const NodeBlock& co s64 cursor) const { if (const auto cbuf = std::get_if(&*tracked)) { // Constant buffer found, test if it's an immediate - const auto offset = cbuf->GetOffset(); + const auto& offset = cbuf->GetOffset(); if (const auto immediate = std::get_if(&*offset)) { return {tracked, cbuf->GetIndex(), immediate->GetValue()}; } -- cgit v1.2.3