mirror of
				https://git.zaroz.cloud/nintendo-back-up/yuzu/yuzu-mainline.git
				synced 2025-03-21 01:53:15 +00:00 
			
		
		
		
	Merge pull request #5164 from lioncash/contains
video_core: Make use of ordered container contains() where applicable
This commit is contained in:
		
						commit
						3415890dd5
					
				@ -545,7 +545,7 @@ private:
 | 
				
			|||||||
    bool IsRegionWritten(VAddr start, VAddr end) const {
 | 
					    bool IsRegionWritten(VAddr start, VAddr end) const {
 | 
				
			||||||
        const u64 page_end = end >> WRITE_PAGE_BIT;
 | 
					        const u64 page_end = end >> WRITE_PAGE_BIT;
 | 
				
			||||||
        for (u64 page_start = start >> WRITE_PAGE_BIT; page_start <= page_end; ++page_start) {
 | 
					        for (u64 page_start = start >> WRITE_PAGE_BIT; page_start <= page_end; ++page_start) {
 | 
				
			||||||
            if (written_pages.count(page_start) > 0) {
 | 
					            if (written_pages.contains(page_start)) {
 | 
				
			||||||
                return true;
 | 
					                return true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -1485,9 +1485,7 @@ void ARBDecompiler::Exit() {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const auto safe_get_register = [this](u32 reg) -> std::string {
 | 
					    const auto safe_get_register = [this](u32 reg) -> std::string {
 | 
				
			||||||
        // TODO(Rodrigo): Replace with contains once C++20 releases
 | 
					        if (ir.GetRegisters().contains(reg)) {
 | 
				
			||||||
        const auto& used_registers = ir.GetRegisters();
 | 
					 | 
				
			||||||
        if (used_registers.find(reg) != used_registers.end()) {
 | 
					 | 
				
			||||||
            return fmt::format("R{}.x", reg);
 | 
					            return fmt::format("R{}.x", reg);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return "{0, 0, 0, 0}.x";
 | 
					        return "{0, 0, 0, 0}.x";
 | 
				
			||||||
 | 
				
			|||||||
@ -459,7 +459,7 @@ void ShaderCacheOpenGL::LoadDiskCache(u64 title_id, const std::atomic_bool& stop
 | 
				
			|||||||
ProgramSharedPtr ShaderCacheOpenGL::GeneratePrecompiledProgram(
 | 
					ProgramSharedPtr ShaderCacheOpenGL::GeneratePrecompiledProgram(
 | 
				
			||||||
    const ShaderDiskCacheEntry& entry, const ShaderDiskCachePrecompiled& precompiled_entry,
 | 
					    const ShaderDiskCacheEntry& entry, const ShaderDiskCachePrecompiled& precompiled_entry,
 | 
				
			||||||
    const std::unordered_set<GLenum>& supported_formats) {
 | 
					    const std::unordered_set<GLenum>& supported_formats) {
 | 
				
			||||||
    if (supported_formats.find(precompiled_entry.binary_format) == supported_formats.end()) {
 | 
					    if (!supported_formats.contains(precompiled_entry.binary_format)) {
 | 
				
			||||||
        LOG_INFO(Render_OpenGL, "Precompiled cache entry with unsupported format, removing");
 | 
					        LOG_INFO(Render_OpenGL, "Precompiled cache entry with unsupported format, removing");
 | 
				
			||||||
        return {};
 | 
					        return {};
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -343,7 +343,7 @@ void ShaderDiskCacheOpenGL::SaveEntry(const ShaderDiskCacheEntry& entry) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const u64 id = entry.unique_identifier;
 | 
					    const u64 id = entry.unique_identifier;
 | 
				
			||||||
    if (stored_transferable.find(id) != stored_transferable.end()) {
 | 
					    if (stored_transferable.contains(id)) {
 | 
				
			||||||
        // The shader already exists
 | 
					        // The shader already exists
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -230,7 +230,7 @@ vk::Pipeline VKGraphicsPipeline::CreatePipeline(const RenderPassParams& renderpa
 | 
				
			|||||||
        if (!attribute.enabled) {
 | 
					        if (!attribute.enabled) {
 | 
				
			||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (input_attributes.find(static_cast<u32>(index)) == input_attributes.end()) {
 | 
					        if (!input_attributes.contains(static_cast<u32>(index))) {
 | 
				
			||||||
            // Skip attributes not used by the vertex shaders.
 | 
					            // Skip attributes not used by the vertex shaders.
 | 
				
			||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -2125,8 +2125,7 @@ private:
 | 
				
			|||||||
            OpStore(z_pointer, depth);
 | 
					            OpStore(z_pointer, depth);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (stage == ShaderType::Fragment) {
 | 
					        if (stage == ShaderType::Fragment) {
 | 
				
			||||||
            const auto SafeGetRegister = [&](u32 reg) {
 | 
					            const auto SafeGetRegister = [this](u32 reg) {
 | 
				
			||||||
                // TODO(Rodrigo): Replace with contains once C++20 releases
 | 
					 | 
				
			||||||
                if (const auto it = registers.find(reg); it != registers.end()) {
 | 
					                if (const auto it = registers.find(reg); it != registers.end()) {
 | 
				
			||||||
                    return OpLoad(t_float, it->second);
 | 
					                    return OpLoad(t_float, it->second);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
				
			|||||||
@ -257,7 +257,7 @@ std::pair<ParseResult, ParseInfo> ParseCode(CFGRebuildState& state, u32 address)
 | 
				
			|||||||
            single_branch.ignore = false;
 | 
					            single_branch.ignore = false;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (state.registered.count(offset) != 0) {
 | 
					        if (state.registered.contains(offset)) {
 | 
				
			||||||
            single_branch.address = offset;
 | 
					            single_branch.address = offset;
 | 
				
			||||||
            single_branch.ignore = true;
 | 
					            single_branch.ignore = true;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
@ -632,12 +632,12 @@ void DecompileShader(CFGRebuildState& state) {
 | 
				
			|||||||
    for (auto label : state.labels) {
 | 
					    for (auto label : state.labels) {
 | 
				
			||||||
        state.manager->DeclareLabel(label);
 | 
					        state.manager->DeclareLabel(label);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    for (auto& block : state.block_info) {
 | 
					    for (const auto& block : state.block_info) {
 | 
				
			||||||
        if (state.labels.count(block.start) != 0) {
 | 
					        if (state.labels.contains(block.start)) {
 | 
				
			||||||
            state.manager->InsertLabel(block.start);
 | 
					            state.manager->InsertLabel(block.start);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        const bool ignore = BlockBranchIsIgnored(block.branch);
 | 
					        const bool ignore = BlockBranchIsIgnored(block.branch);
 | 
				
			||||||
        u32 end = ignore ? block.end + 1 : block.end;
 | 
					        const u32 end = ignore ? block.end + 1 : block.end;
 | 
				
			||||||
        state.manager->InsertBlock(block.start, end);
 | 
					        state.manager->InsertBlock(block.start, end);
 | 
				
			||||||
        if (!ignore) {
 | 
					        if (!ignore) {
 | 
				
			||||||
            InsertBranch(*state.manager, block.branch);
 | 
					            InsertBranch(*state.manager, block.branch);
 | 
				
			||||||
@ -737,7 +737,7 @@ std::unique_ptr<ShaderCharacteristics> ScanFlow(const ProgramCode& program_code,
 | 
				
			|||||||
    auto back = result_out->blocks.begin();
 | 
					    auto back = result_out->blocks.begin();
 | 
				
			||||||
    auto next = std::next(back);
 | 
					    auto next = std::next(back);
 | 
				
			||||||
    while (next != result_out->blocks.end()) {
 | 
					    while (next != result_out->blocks.end()) {
 | 
				
			||||||
        if (state.labels.count(next->start) == 0 && next->start == back->end + 1) {
 | 
					        if (!state.labels.contains(next->start) && next->start == back->end + 1) {
 | 
				
			||||||
            back->end = next->end;
 | 
					            back->end = next->end;
 | 
				
			||||||
            next = result_out->blocks.erase(next);
 | 
					            next = result_out->blocks.erase(next);
 | 
				
			||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
 | 
				
			|||||||
@ -153,8 +153,8 @@ void ShaderIR::Decode() {
 | 
				
			|||||||
        const auto& blocks = shader_info.blocks;
 | 
					        const auto& blocks = shader_info.blocks;
 | 
				
			||||||
        NodeBlock current_block;
 | 
					        NodeBlock current_block;
 | 
				
			||||||
        u32 current_label = static_cast<u32>(exit_branch);
 | 
					        u32 current_label = static_cast<u32>(exit_branch);
 | 
				
			||||||
        for (auto& block : blocks) {
 | 
					        for (const auto& block : blocks) {
 | 
				
			||||||
            if (shader_info.labels.count(block.start) != 0) {
 | 
					            if (shader_info.labels.contains(block.start)) {
 | 
				
			||||||
                insert_block(current_block, current_label);
 | 
					                insert_block(current_block, current_label);
 | 
				
			||||||
                current_block.clear();
 | 
					                current_block.clear();
 | 
				
			||||||
                current_label = block.start;
 | 
					                current_label = block.start;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user