diff --git a/README.md b/README.md index f8541515e..4f6fa0770 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2808. +This is the source code for early-access 2810. ## Legal Notice diff --git a/src/common/address_space.cpp b/src/common/address_space.cpp index 866e78dbe..6db85be87 100755 --- a/src/common/address_space.cpp +++ b/src/common/address_space.cpp @@ -1,5 +1,6 @@ -// SPDX-FileCopyrightText: 2021 Skyline Team and Contributors -// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright © 2021 Skyline Team and Contributors (https://github.com/skyline-emu/) +// Licensed under GPLv3 or any later version +// Refer to the license.txt file included. #include "common/address_space.inc" diff --git a/src/common/address_space.h b/src/common/address_space.h index 9222b2fdc..8e13935af 100755 --- a/src/common/address_space.h +++ b/src/common/address_space.h @@ -1,5 +1,6 @@ -// SPDX-FileCopyrightText: 2021 Skyline Team and Contributors -// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright © 2021 Skyline Team and Contributors (https://github.com/skyline-emu/) +// Licensed under GPLv3 or any later version +// Refer to the license.txt file included. #pragma once @@ -23,29 +24,9 @@ template requires AddressSpaceValid class FlatAddressSpaceMap { -public: - /// The maximum VA that this AS can technically reach - static constexpr VaType VaMaximum{(1ULL << (AddressSpaceBits - 1)) + - ((1ULL << (AddressSpaceBits - 1)) - 1)}; - - explicit FlatAddressSpaceMap(VaType va_limit, - std::function unmap_callback = {}); - - FlatAddressSpaceMap() = default; - - void Map(VaType virt, PaType phys, VaType size, ExtraBlockInfo extra_info = {}) { - std::scoped_lock lock(block_mutex); - MapLocked(virt, phys, size, extra_info); - } - - void Unmap(VaType virt, VaType size) { - std::scoped_lock lock(block_mutex); - UnmapLocked(virt, size); - } - - VaType GetVALimit() const { - return va_limit; - } +private: + std::function + unmapCallback{}; //!< Callback called when the mappings in an region have changed protected: /** @@ -53,55 +34,68 @@ protected: * another block with a different phys address is hit */ struct Block { - /// VA of the block - VaType virt{UnmappedVa}; - /// PA of the block, will increase 1-1 with VA until a new block is encountered - PaType phys{UnmappedPa}; - [[no_unique_address]] ExtraBlockInfo extra_info; + VaType virt{UnmappedVa}; //!< VA of the block + PaType phys{UnmappedPa}; //!< PA of the block, will increase 1-1 with VA until a new block + //!< is encountered + [[no_unique_address]] ExtraBlockInfo extraInfo; Block() = default; - Block(VaType virt_, PaType phys_, ExtraBlockInfo extra_info_) - : virt(virt_), phys(phys_), extra_info(extra_info_) {} + Block(VaType virt_, PaType phys_, ExtraBlockInfo extraInfo_) + : virt(virt_), phys(phys_), extraInfo(extraInfo_) {} - bool Valid() const { + constexpr bool Valid() { return virt != UnmappedVa; } - bool Mapped() const { + constexpr bool Mapped() { return phys != UnmappedPa; } - bool Unmapped() const { + constexpr bool Unmapped() { return phys == UnmappedPa; } - bool operator<(const VaType& p_virt) const { - return virt < p_virt; + bool operator<(const VaType& pVirt) const { + return virt < pVirt; } }; + std::mutex blockMutex; + std::vector blocks{Block{}}; + /** * @brief Maps a PA range into the given AS region - * @note block_mutex MUST be locked when calling this + * @note blockMutex MUST be locked when calling this */ - void MapLocked(VaType virt, PaType phys, VaType size, ExtraBlockInfo extra_info); + void MapLocked(VaType virt, PaType phys, VaType size, ExtraBlockInfo extraInfo); /** * @brief Unmaps the given range and merges it with other unmapped regions - * @note block_mutex MUST be locked when calling this + * @note blockMutex MUST be locked when calling this */ void UnmapLocked(VaType virt, VaType size); - std::mutex block_mutex; - std::vector blocks{Block{}}; +public: + static constexpr VaType VaMaximum{(1ULL << (AddressSpaceBits - 1)) + + ((1ULL << (AddressSpaceBits - 1)) - + 1)}; //!< The maximum VA that this AS can technically reach - /// a soft limit on the maximum VA of the AS - VaType va_limit{VaMaximum}; + VaType vaLimit{VaMaximum}; //!< A soft limit on the maximum VA of the AS -private: - /// Callback called when the mappings in an region have changed - std::function unmap_callback{}; + FlatAddressSpaceMap(VaType vaLimit, std::function unmapCallback = {}); + + FlatAddressSpaceMap() = default; + + void Map(VaType virt, PaType phys, VaType size, ExtraBlockInfo extraInfo = {}) { + std::scoped_lock lock(blockMutex); + MapLocked(virt, phys, size, extraInfo); + } + + void Unmap(VaType virt, VaType size) { + std::scoped_lock lock(blockMutex); + UnmapLocked(virt, size); + } }; /** @@ -115,8 +109,14 @@ class FlatAllocator private: using Base = FlatAddressSpaceMap; + VaType currentLinearAllocEnd; //!< The end address for the initial linear allocation pass, once + //!< this reaches the AS limit the slower allocation path will be + //!< used + public: - explicit FlatAllocator(VaType virt_start, VaType va_limit = Base::VaMaximum); + VaType vaStart; //!< The base VA of the allocator, no allocations will be below this + + FlatAllocator(VaType vaStart, VaType vaLimit = Base::VaMaximum); /** * @brief Allocates a region in the AS of the given size and returns its address @@ -132,19 +132,5 @@ public: * @brief Frees an AS region so it can be used again */ void Free(VaType virt, VaType size); - - VaType GetVAStart() const { - return virt_start; - } - -private: - /// The base VA of the allocator, no allocations will be below this - VaType virt_start; - - /** - * The end address for the initial linear allocation pass - * Once this reaches the AS limit the slower allocation path will be used - */ - VaType current_linear_alloc_end; }; } // namespace Common diff --git a/src/common/address_space.inc b/src/common/address_space.inc index 9f957c81d..7cfbb150b 100755 --- a/src/common/address_space.inc +++ b/src/common/address_space.inc @@ -1,5 +1,5 @@ -// SPDX-FileCopyrightText: 2021 Skyline Team and Contributors -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-License-Identifier: GPLv3 or later +// Copyright © 2021 Skyline Team and Contributors (https://github.com/skyline-emu/) #include "common/address_space.h" #include "common/assert.h" @@ -30,151 +30,137 @@ FlatAllocator namespace Common { -MAP_MEMBER_CONST()::FlatAddressSpaceMap(VaType va_limit_, - std::function unmap_callback_) - : va_limit{va_limit_}, unmap_callback{std::move(unmap_callback_)} { - if (va_limit > VaMaximum) { +MAP_MEMBER_CONST()::FlatAddressSpaceMap(VaType vaLimit_, + std::function unmapCallback_) + : unmapCallback(std::move(unmapCallback_)), vaLimit(vaLimit_) { + if (vaLimit > VaMaximum) UNREACHABLE_MSG("Invalid VA limit!"); - } } -MAP_MEMBER(void)::MapLocked(VaType virt, PaType phys, VaType size, ExtraBlockInfo extra_info) { - VaType virt_end{virt + size}; +MAP_MEMBER(void)::MapLocked(VaType virt, PaType phys, VaType size, ExtraBlockInfo extraInfo) { + VaType virtEnd{virt + size}; - if (virt_end > va_limit) { - UNREACHABLE_MSG( - "Trying to map a block past the VA limit: virt_end: 0x{:X}, va_limit: 0x{:X}", virt_end, - va_limit); - } + if (virtEnd > vaLimit) + UNREACHABLE_MSG("Trying to map a block past the VA limit: virtEnd: 0x{:X}, vaLimit: 0x{:X}", + virtEnd, vaLimit); - auto block_end_successor{std::lower_bound(blocks.begin(), blocks.end(), virt_end)}; - if (block_end_successor == blocks.begin()) { - UNREACHABLE_MSG("Trying to map a block before the VA start: virt_end: 0x{:X}", virt_end); - } + auto blockEndSuccessor{std::lower_bound(blocks.begin(), blocks.end(), virtEnd)}; + if (blockEndSuccessor == blocks.begin()) + UNREACHABLE_MSG("Trying to map a block before the VA start: virtEnd: 0x{:X}", virtEnd); - auto block_end_predecessor{std::prev(block_end_successor)}; + auto blockEndPredecessor{std::prev(blockEndSuccessor)}; - if (block_end_successor != blocks.end()) { + if (blockEndSuccessor != blocks.end()) { // We have blocks in front of us, if one is directly in front then we don't have to add a // tail - if (block_end_successor->virt != virt_end) { + if (blockEndSuccessor->virt != virtEnd) { PaType tailPhys{[&]() -> PaType { if constexpr (!PaContigSplit) { - // Always propagate unmapped regions rather than calculating offset - return block_end_predecessor->phys; + return blockEndPredecessor + ->phys; // Always propagate unmapped regions rather than calculating offset } else { - if (block_end_predecessor->Unmapped()) { - // Always propagate unmapped regions rather than calculating offset - return block_end_predecessor->phys; - } else { - return block_end_predecessor->phys + virt_end - block_end_predecessor->virt; - } + if (blockEndPredecessor->Unmapped()) + return blockEndPredecessor->phys; // Always propagate unmapped regions + // rather than calculating offset + else + return blockEndPredecessor->phys + virtEnd - blockEndPredecessor->virt; } }()}; - if (block_end_predecessor->virt >= virt) { + if (blockEndPredecessor->virt >= virt) { // If this block's start would be overlapped by the map then reuse it as a tail // block - block_end_predecessor->virt = virt_end; - block_end_predecessor->phys = tailPhys; - block_end_predecessor->extra_info = block_end_predecessor->extra_info; + blockEndPredecessor->virt = virtEnd; + blockEndPredecessor->phys = tailPhys; + blockEndPredecessor->extraInfo = blockEndPredecessor->extraInfo; // No longer predecessor anymore - block_end_successor = block_end_predecessor--; + blockEndSuccessor = blockEndPredecessor--; } else { // Else insert a new one and we're done - blocks.insert(block_end_successor, - {Block(virt, phys, extra_info), - Block(virt_end, tailPhys, block_end_predecessor->extra_info)}); - if (unmap_callback) { - unmap_callback(virt, size); - } + blocks.insert(blockEndSuccessor, + {Block(virt, phys, extraInfo), + Block(virtEnd, tailPhys, blockEndPredecessor->extraInfo)}); + if (unmapCallback) + unmapCallback(virt, size); return; } } } else { - // block_end_predecessor will always be unmapped as blocks has to be terminated by an - // unmapped chunk - if (block_end_predecessor != blocks.begin() && block_end_predecessor->virt >= virt) { + // blockEndPredecessor will always be unmapped as blocks has to be terminated by an unmapped + // chunk + if (blockEndPredecessor != blocks.begin() && blockEndPredecessor->virt >= virt) { // Move the unmapped block start backwards - block_end_predecessor->virt = virt_end; + blockEndPredecessor->virt = virtEnd; // No longer predecessor anymore - block_end_successor = block_end_predecessor--; + blockEndSuccessor = blockEndPredecessor--; } else { // Else insert a new one and we're done - blocks.insert(block_end_successor, - {Block(virt, phys, extra_info), Block(virt_end, UnmappedPa, {})}); - if (unmap_callback) { - unmap_callback(virt, size); - } + blocks.insert(blockEndSuccessor, + {Block(virt, phys, extraInfo), Block(virtEnd, UnmappedPa, {})}); + if (unmapCallback) + unmapCallback(virt, size); return; } } - auto block_start_successor{block_end_successor}; + auto blockStartSuccessor{blockEndSuccessor}; // Walk the block vector to find the start successor as this is more efficient than another // binary search in most scenarios - while (std::prev(block_start_successor)->virt >= virt) { - block_start_successor--; - } + while (std::prev(blockStartSuccessor)->virt >= virt) + blockStartSuccessor--; // Check that the start successor is either the end block or something in between - if (block_start_successor->virt > virt_end) { - UNREACHABLE_MSG("Unsorted block in AS map: virt: 0x{:X}", block_start_successor->virt); - } else if (block_start_successor->virt == virt_end) { + if (blockStartSuccessor->virt > virtEnd) { + UNREACHABLE_MSG("Unsorted block in AS map: virt: 0x{:X}", blockStartSuccessor->virt); + } else if (blockStartSuccessor->virt == virtEnd) { // We need to create a new block as there are none spare that we would overwrite - blocks.insert(block_start_successor, Block(virt, phys, extra_info)); + blocks.insert(blockStartSuccessor, Block(virt, phys, extraInfo)); } else { // Erase overwritten blocks - if (auto eraseStart{std::next(block_start_successor)}; eraseStart != block_end_successor) { - blocks.erase(eraseStart, block_end_successor); - } + if (auto eraseStart{std::next(blockStartSuccessor)}; eraseStart != blockEndSuccessor) + blocks.erase(eraseStart, blockEndSuccessor); // Reuse a block that would otherwise be overwritten as a start block - block_start_successor->virt = virt; - block_start_successor->phys = phys; - block_start_successor->extra_info = extra_info; + blockStartSuccessor->virt = virt; + blockStartSuccessor->phys = phys; + blockStartSuccessor->extraInfo = extraInfo; } - if (unmap_callback) { - unmap_callback(virt, size); - } + if (unmapCallback) + unmapCallback(virt, size); } MAP_MEMBER(void)::UnmapLocked(VaType virt, VaType size) { - VaType virt_end{virt + size}; + VaType virtEnd{virt + size}; - if (virt_end > va_limit) { - UNREACHABLE_MSG( - "Trying to map a block past the VA limit: virt_end: 0x{:X}, va_limit: 0x{:X}", virt_end, - va_limit); - } + if (virtEnd > vaLimit) + UNREACHABLE_MSG("Trying to map a block past the VA limit: virtEnd: 0x{:X}, vaLimit: 0x{:X}", + virtEnd, vaLimit); - auto block_end_successor{std::lower_bound(blocks.begin(), blocks.end(), virt_end)}; - if (block_end_successor == blocks.begin()) { - UNREACHABLE_MSG("Trying to unmap a block before the VA start: virt_end: 0x{:X}", virt_end); - } + auto blockEndSuccessor{std::lower_bound(blocks.begin(), blocks.end(), virtEnd)}; + if (blockEndSuccessor == blocks.begin()) + UNREACHABLE_MSG("Trying to unmap a block before the VA start: virtEnd: 0x{:X}", virtEnd); - auto block_end_predecessor{std::prev(block_end_successor)}; + auto blockEndPredecessor{std::prev(blockEndSuccessor)}; - auto walk_back_to_predecessor{[&](auto iter) { - while (iter->virt >= virt) { + auto walkBackToPredecessor{[&](auto iter) { + while (iter->virt >= virt) iter--; - } return iter; }}; - auto erase_blocks_with_end_unmapped{[&](auto unmappedEnd) { - auto block_start_predecessor{walk_back_to_predecessor(unmappedEnd)}; - auto block_start_successor{std::next(block_start_predecessor)}; + auto eraseBlocksWithEndUnmapped{[&](auto unmappedEnd) { + auto blockStartPredecessor{walkBackToPredecessor(unmappedEnd)}; + auto blockStartSuccessor{std::next(blockStartPredecessor)}; auto eraseEnd{[&]() { - if (block_start_predecessor->Unmapped()) { + if (blockStartPredecessor->Unmapped()) { // If the start predecessor is unmapped then we can erase everything in our region // and be done return std::next(unmappedEnd); @@ -188,171 +174,158 @@ MAP_MEMBER(void)::UnmapLocked(VaType virt, VaType size) { // We can't have two unmapped regions after each other if (eraseEnd != blocks.end() && - (eraseEnd == block_start_successor || - (block_start_predecessor->Unmapped() && eraseEnd->Unmapped()))) { + (eraseEnd == blockStartSuccessor || + (blockStartPredecessor->Unmapped() && eraseEnd->Unmapped()))) UNREACHABLE_MSG("Multiple contiguous unmapped regions are unsupported!"); - } - blocks.erase(block_start_successor, eraseEnd); + blocks.erase(blockStartSuccessor, eraseEnd); }}; // We can avoid any splitting logic if these are the case - if (block_end_predecessor->Unmapped()) { - if (block_end_predecessor->virt > virt) { - erase_blocks_with_end_unmapped(block_end_predecessor); - } + if (blockEndPredecessor->Unmapped()) { + if (blockEndPredecessor->virt > virt) + eraseBlocksWithEndUnmapped(blockEndPredecessor); - if (unmap_callback) { - unmap_callback(virt, size); - } + if (unmapCallback) + unmapCallback(virt, size); return; // The region is unmapped, bail out early - } else if (block_end_successor->virt == virt_end && block_end_successor->Unmapped()) { - erase_blocks_with_end_unmapped(block_end_successor); + } else if (blockEndSuccessor->virt == virtEnd && blockEndSuccessor->Unmapped()) { + eraseBlocksWithEndUnmapped(blockEndSuccessor); - if (unmap_callback) { - unmap_callback(virt, size); - } + if (unmapCallback) + unmapCallback(virt, size); return; // The region is unmapped here and doesn't need splitting, bail out early - } else if (block_end_successor == blocks.end()) { + } else if (blockEndSuccessor == blocks.end()) { // This should never happen as the end should always follow an unmapped block UNREACHABLE_MSG("Unexpected Memory Manager state!"); - } else if (block_end_successor->virt != virt_end) { + } else if (blockEndSuccessor->virt != virtEnd) { // If one block is directly in front then we don't have to add a tail // The previous block is mapped so we will need to add a tail with an offset PaType tailPhys{[&]() { - if constexpr (PaContigSplit) { - return block_end_predecessor->phys + virt_end - block_end_predecessor->virt; - } else { - return block_end_predecessor->phys; - } + if constexpr (PaContigSplit) + return blockEndPredecessor->phys + virtEnd - blockEndPredecessor->virt; + else + return blockEndPredecessor->phys; }()}; - if (block_end_predecessor->virt >= virt) { + if (blockEndPredecessor->virt >= virt) { // If this block's start would be overlapped by the unmap then reuse it as a tail block - block_end_predecessor->virt = virt_end; - block_end_predecessor->phys = tailPhys; + blockEndPredecessor->virt = virtEnd; + blockEndPredecessor->phys = tailPhys; // No longer predecessor anymore - block_end_successor = block_end_predecessor--; + blockEndSuccessor = blockEndPredecessor--; } else { - blocks.insert(block_end_successor, + blocks.insert(blockEndSuccessor, {Block(virt, UnmappedPa, {}), - Block(virt_end, tailPhys, block_end_predecessor->extra_info)}); - if (unmap_callback) { - unmap_callback(virt, size); - } + Block(virtEnd, tailPhys, blockEndPredecessor->extraInfo)}); + if (unmapCallback) + unmapCallback(virt, size); - // The previous block is mapped and ends before - return; + return; // The previous block is mapped and ends before } } // Walk the block vector to find the start predecessor as this is more efficient than another // binary search in most scenarios - auto block_start_predecessor{walk_back_to_predecessor(block_end_successor)}; - auto block_start_successor{std::next(block_start_predecessor)}; + auto blockStartPredecessor{walkBackToPredecessor(blockEndSuccessor)}; + auto blockStartSuccessor{std::next(blockStartPredecessor)}; - if (block_start_successor->virt > virt_end) { - UNREACHABLE_MSG("Unsorted block in AS map: virt: 0x{:X}", block_start_successor->virt); - } else if (block_start_successor->virt == virt_end) { + if (blockStartSuccessor->virt > virtEnd) { + UNREACHABLE_MSG("Unsorted block in AS map: virt: 0x{:X}", blockStartSuccessor->virt); + } else if (blockStartSuccessor->virt == virtEnd) { // There are no blocks between the start and the end that would let us skip inserting a new // one for head // The previous block is may be unmapped, if so we don't need to insert any unmaps after it - if (block_start_predecessor->Mapped()) { - blocks.insert(block_start_successor, Block(virt, UnmappedPa, {})); - } - } else if (block_start_predecessor->Unmapped()) { + if (blockStartPredecessor->Mapped()) + blocks.insert(blockStartSuccessor, Block(virt, UnmappedPa, {})); + } else if (blockStartPredecessor->Unmapped()) { // If the previous block is unmapped - blocks.erase(block_start_successor, block_end_predecessor); + blocks.erase(blockStartSuccessor, blockEndPredecessor); } else { // Erase overwritten blocks, skipping the first one as we have written the unmapped start // block there - if (auto eraseStart{std::next(block_start_successor)}; eraseStart != block_end_successor) { - blocks.erase(eraseStart, block_end_successor); - } + if (auto eraseStart{std::next(blockStartSuccessor)}; eraseStart != blockEndSuccessor) + blocks.erase(eraseStart, blockEndSuccessor); // Add in the unmapped block header - block_start_successor->virt = virt; - block_start_successor->phys = UnmappedPa; + blockStartSuccessor->virt = virt; + blockStartSuccessor->phys = UnmappedPa; } - if (unmap_callback) - unmap_callback(virt, size); + if (unmapCallback) + unmapCallback(virt, size); } -ALLOC_MEMBER_CONST()::FlatAllocator(VaType virt_start_, VaType va_limit_) - : Base{va_limit_}, virt_start{virt_start_}, current_linear_alloc_end{virt_start_} {} +ALLOC_MEMBER_CONST()::FlatAllocator(VaType vaStart_, VaType vaLimit_) + : Base(vaLimit_), currentLinearAllocEnd(vaStart_), vaStart(vaStart_) {} ALLOC_MEMBER(VaType)::Allocate(VaType size) { - std::scoped_lock lock(this->block_mutex); + std::scoped_lock lock(this->blockMutex); - VaType alloc_start{UnmappedVa}; - VaType alloc_end{current_linear_alloc_end + size}; + VaType allocStart{UnmappedVa}; + VaType allocEnd{currentLinearAllocEnd + size}; // Avoid searching backwards in the address space if possible - if (alloc_end >= current_linear_alloc_end && alloc_end <= this->va_limit) { - auto alloc_end_successor{ - std::lower_bound(this->blocks.begin(), this->blocks.end(), alloc_end)}; - if (alloc_end_successor == this->blocks.begin()) { + if (allocEnd >= currentLinearAllocEnd && allocEnd <= this->vaLimit) { + auto allocEndSuccessor{ + std::lower_bound(this->blocks.begin(), this->blocks.end(), allocEnd)}; + if (allocEndSuccessor == this->blocks.begin()) UNREACHABLE_MSG("First block in AS map is invalid!"); - } - auto alloc_end_predecessor{std::prev(alloc_end_successor)}; - if (alloc_end_predecessor->virt <= current_linear_alloc_end) { - alloc_start = current_linear_alloc_end; + auto allocEndPredecessor{std::prev(allocEndSuccessor)}; + if (allocEndPredecessor->virt <= currentLinearAllocEnd) { + allocStart = currentLinearAllocEnd; } else { // Skip over fixed any mappings in front of us - while (alloc_end_successor != this->blocks.end()) { - if (alloc_end_successor->virt - alloc_end_predecessor->virt < size || - alloc_end_predecessor->Mapped()) { - alloc_start = alloc_end_predecessor->virt; + while (allocEndSuccessor != this->blocks.end()) { + if (allocEndSuccessor->virt - allocEndPredecessor->virt < size || + allocEndPredecessor->Mapped()) { + allocStart = allocEndPredecessor->virt; break; } - alloc_end_predecessor = alloc_end_successor++; + allocEndPredecessor = allocEndSuccessor++; // Use the VA limit to calculate if we can fit in the final block since it has no // successor - if (alloc_end_successor == this->blocks.end()) { - alloc_end = alloc_end_predecessor->virt + size; + if (allocEndSuccessor == this->blocks.end()) { + allocEnd = allocEndPredecessor->virt + size; - if (alloc_end >= alloc_end_predecessor->virt && alloc_end <= this->va_limit) { - alloc_start = alloc_end_predecessor->virt; - } + if (allocEnd >= allocEndPredecessor->virt && allocEnd <= this->vaLimit) + allocStart = allocEndPredecessor->virt; } } } } - if (alloc_start != UnmappedVa) { - current_linear_alloc_end = alloc_start + size; + if (allocStart != UnmappedVa) { + currentLinearAllocEnd = allocStart + size; } else { // If linear allocation overflows the AS then find a gap - if (this->blocks.size() <= 2) { + if (this->blocks.size() <= 2) UNREACHABLE_MSG("Unexpected allocator state!"); + + auto searchPredecessor{this->blocks.begin()}; + auto searchSuccessor{std::next(searchPredecessor)}; + + while (searchSuccessor != this->blocks.end() && + (searchSuccessor->virt - searchPredecessor->virt < size || + searchPredecessor->Mapped())) { + searchPredecessor = searchSuccessor++; } - auto search_predecessor{this->blocks.begin()}; - auto search_successor{std::next(search_predecessor)}; - - while (search_successor != this->blocks.end() && - (search_successor->virt - search_predecessor->virt < size || - search_predecessor->Mapped())) { - search_predecessor = search_successor++; - } - - if (search_successor != this->blocks.end()) { - alloc_start = search_predecessor->virt; - } else { + if (searchSuccessor != this->blocks.end()) + allocStart = searchPredecessor->virt; + else return {}; // AS is full - } } - this->MapLocked(alloc_start, true, size, {}); - return alloc_start; + this->MapLocked(allocStart, true, size, {}); + return allocStart; } ALLOC_MEMBER(void)::AllocateFixed(VaType virt, VaType size) { diff --git a/src/common/multi_level_page_table.h b/src/common/multi_level_page_table.h index 08092c89a..dde1cc962 100755 --- a/src/common/multi_level_page_table.h +++ b/src/common/multi_level_page_table.h @@ -1,5 +1,6 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. #pragma once diff --git a/src/common/multi_level_page_table.inc b/src/common/multi_level_page_table.inc index 8ac506fa0..4def6dba8 100755 --- a/src/common/multi_level_page_table.inc +++ b/src/common/multi_level_page_table.inc @@ -1,5 +1,6 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. #ifdef _WIN32 #include diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp index fd6928105..9fc78f033 100755 --- a/src/core/cpu_manager.cpp +++ b/src/core/cpu_manager.cpp @@ -194,7 +194,9 @@ void CpuManager::PreemptSingleCore(bool from_running_enviroment) { { auto& scheduler = system.Kernel().Scheduler(current_core); scheduler.Reload(scheduler.GetSchedulerCurrentThread()); - idle_count = 0; + if (!scheduler.IsIdle()) { + idle_count = 0; + } } } diff --git a/src/core/hle/kernel/k_scheduler.h b/src/core/hle/kernel/k_scheduler.h index 3f90656ee..cc3da33f5 100755 --- a/src/core/hle/kernel/k_scheduler.h +++ b/src/core/hle/kernel/k_scheduler.h @@ -55,6 +55,11 @@ public: return idle_thread; } + /// Returns true if the scheduler is idle + [[nodiscard]] bool IsIdle() const { + return GetSchedulerCurrentThread() == idle_thread; + } + /// Gets the timestamp for the last context switch in ticks. [[nodiscard]] u64 GetLastContextSwitchTicks() const; diff --git a/src/core/hle/service/nvdrv/core/container.cpp b/src/core/hle/service/nvdrv/core/container.cpp index d2a632646..4175d3d9c 100755 --- a/src/core/hle/service/nvdrv/core/container.cpp +++ b/src/core/hle/service/nvdrv/core/container.cpp @@ -1,6 +1,7 @@ -// SPDX-FileCopyrightText: 2022 yuzu Emulator Project -// SPDX-FileCopyrightText: 2022 Skyline Team and Contributors -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2022 yuzu emulator team and Skyline Team and Contributors +// (https://github.com/skyline-emu/) +// SPDX-License-Identifier: GPL-3.0-or-later Licensed under GPLv3 +// or any later version Refer to the license.txt file included. #include "core/hle/service/nvdrv/core/container.h" #include "core/hle/service/nvdrv/core/nvmap.h" diff --git a/src/core/hle/service/nvdrv/core/container.h b/src/core/hle/service/nvdrv/core/container.h index 5c8b95803..e069ade4e 100755 --- a/src/core/hle/service/nvdrv/core/container.h +++ b/src/core/hle/service/nvdrv/core/container.h @@ -1,6 +1,7 @@ -// SPDX-FileCopyrightText: 2022 yuzu Emulator Project -// SPDX-FileCopyrightText: 2022 Skyline Team and Contributors -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2022 yuzu emulator team and Skyline Team and Contributors +// (https://github.com/skyline-emu/) +// SPDX-License-Identifier: GPL-3.0-or-later Licensed under GPLv3 +// or any later version Refer to the license.txt file included. #pragma once diff --git a/src/core/hle/service/nvdrv/core/nvmap.cpp b/src/core/hle/service/nvdrv/core/nvmap.cpp index 942c2ac38..343fb5fe4 100755 --- a/src/core/hle/service/nvdrv/core/nvmap.cpp +++ b/src/core/hle/service/nvdrv/core/nvmap.cpp @@ -1,6 +1,7 @@ -// SPDX-FileCopyrightText: 2022 yuzu Emulator Project -// SPDX-FileCopyrightText: 2022 Skyline Team and Contributors -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2022 yuzu emulator team and Skyline Team and Contributors +// (https://github.com/skyline-emu/) +// SPDX-License-Identifier: GPL-3.0-or-later Licensed under GPLv3 +// or any later version Refer to the license.txt file included. #include "common/alignment.h" #include "common/assert.h" diff --git a/src/core/hle/service/nvdrv/core/nvmap.h b/src/core/hle/service/nvdrv/core/nvmap.h index 6d6dac023..ef2df3ad7 100755 --- a/src/core/hle/service/nvdrv/core/nvmap.h +++ b/src/core/hle/service/nvdrv/core/nvmap.h @@ -1,6 +1,7 @@ -// SPDX-FileCopyrightText: 2022 yuzu Emulator Project -// SPDX-FileCopyrightText: 2022 Skyline Team and Contributors -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2022 yuzu emulator team and Skyline Team and Contributors +// (https://github.com/skyline-emu/) +// SPDX-License-Identifier: GPL-3.0-or-later Licensed under GPLv3 +// or any later version Refer to the license.txt file included. #pragma once diff --git a/src/core/hle/service/nvdrv/core/syncpoint_manager.cpp b/src/core/hle/service/nvdrv/core/syncpoint_manager.cpp index 0bb2aec97..fc4ff3c2f 100755 --- a/src/core/hle/service/nvdrv/core/syncpoint_manager.cpp +++ b/src/core/hle/service/nvdrv/core/syncpoint_manager.cpp @@ -1,6 +1,7 @@ -// SPDX-FileCopyrightText: 2022 yuzu Emulator Project -// SPDX-FileCopyrightText: 2022 Skyline Team and Contributors -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2022 yuzu emulator team and Skyline Team and Contributors +// (https://github.com/skyline-emu/) +// SPDX-License-Identifier: GPL-3.0-or-later Licensed under GPLv3 +// or any later version Refer to the license.txt file included. #include "common/assert.h" #include "core/hle/service/nvdrv/core/syncpoint_manager.h" diff --git a/src/core/hle/service/nvdrv/core/syncpoint_manager.h b/src/core/hle/service/nvdrv/core/syncpoint_manager.h index 6b71cd33d..da456f206 100755 --- a/src/core/hle/service/nvdrv/core/syncpoint_manager.h +++ b/src/core/hle/service/nvdrv/core/syncpoint_manager.h @@ -1,6 +1,7 @@ -// SPDX-FileCopyrightText: 2022 yuzu Emulator Project -// SPDX-FileCopyrightText: 2022 Skyline Team and Contributors -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2022 yuzu emulator team and Skyline Team and Contributors +// (https://github.com/skyline-emu/) +// SPDX-License-Identifier: GPL-3.0-or-later Licensed under GPLv3 +// or any later version Refer to the license.txt file included. #pragma once diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp index 845429266..9fd607248 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp @@ -1,6 +1,7 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-FileCopyrightText: 2021 Skyline Team and Contributors -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2021 yuzu emulator team, Skyline Team and Contributors +// (https://github.com/skyline-emu/) +// SPDX-License-Identifier: GPL-3.0-or-later Licensed under GPLv3 +// or any later version Refer to the license.txt file included. #include #include @@ -472,16 +473,16 @@ void nvhost_as_gpu::GetVARegionsImpl(IoctlGetVaRegions& params) { params.regions = std::array{ VaRegion{ - .offset = vm.small_page_allocator->GetVAStart() << VM::PAGE_SIZE_BITS, + .offset = vm.small_page_allocator->vaStart << VM::PAGE_SIZE_BITS, .page_size = VM::PAGE_SIZE, ._pad0_{}, - .pages = vm.small_page_allocator->GetVALimit() - vm.small_page_allocator->GetVAStart(), + .pages = vm.small_page_allocator->vaLimit - vm.small_page_allocator->vaStart, }, VaRegion{ - .offset = vm.big_page_allocator->GetVAStart() << vm.big_page_size_bits, + .offset = vm.big_page_allocator->vaStart << vm.big_page_size_bits, .page_size = vm.big_page_size, ._pad0_{}, - .pages = vm.big_page_allocator->GetVALimit() - vm.big_page_allocator->GetVAStart(), + .pages = vm.big_page_allocator->vaLimit - vm.big_page_allocator->vaStart, }, }; } diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h index bb1493510..fe1bc750d 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h @@ -1,6 +1,7 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-FileCopyrightText: 2021 Skyline Team and Contributors -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2021 yuzu emulator team, Skyline Team and Contributors +// (https://github.com/skyline-emu/) +// SPDX-License-Identifier: GPL-3.0-or-later Licensed under GPLv3 +// or any later version Refer to the license.txt file included. #pragma once diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index 5bee4a3d3..7fffb8e48 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp @@ -1,6 +1,7 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-FileCopyrightText: 2021 Skyline Team and Contributors -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2021 yuzu emulator team, Skyline Team and Contributors +// (https://github.com/skyline-emu/) +// SPDX-License-Identifier: GPL-3.0-or-later Licensed under GPLv3 +// or any later version Refer to the license.txt file included. #include #include diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h index 4aa738b41..f511c0296 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h @@ -1,6 +1,7 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-FileCopyrightText: 2021 Skyline Team and Contributors -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2021 yuzu emulator team, Skyline Team and Contributors +// (https://github.com/skyline-emu/) +// SPDX-License-Identifier: GPL-3.0-or-later Licensed under GPLv3 +// or any later version Refer to the license.txt file included. #pragma once diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp index fe83423d5..2ec1ad3e9 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp @@ -47,15 +47,21 @@ std::size_t WriteVectors(std::vector& dst, const std::vector& src, std::s } // Anonymous namespace std::unordered_map nvhost_nvdec_common::fd_to_id{}; +std::deque nvhost_nvdec_common::syncpts_accumulated{}; nvhost_nvdec_common::nvhost_nvdec_common(Core::System& system_, NvCore::Container& core_, NvCore::ChannelType channel_type_) : nvdevice{system_}, core{core_}, syncpoint_manager{core.GetSyncpointManager()}, nvmap{core.GetNvMapFile()}, channel_type{channel_type_} { - channel_syncpoint = syncpoint_manager.AllocateSyncpoint(false); + if (syncpts_accumulated.empty()) { + channel_syncpoint = syncpoint_manager.AllocateSyncpoint(false); + } else { + channel_syncpoint = syncpts_accumulated.front(); + syncpts_accumulated.pop_front(); + } } nvhost_nvdec_common::~nvhost_nvdec_common() { - syncpoint_manager.FreeSyncpoint(channel_syncpoint); + syncpts_accumulated.push_back(channel_syncpoint); } NvResult nvhost_nvdec_common::SetNVMAPfd(const std::vector& input) { diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h index 4046b0e13..93990bb9b 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include "common/common_types.h" #include "common/swap.h" @@ -127,6 +128,8 @@ protected: NvCore::NvMap& nvmap; NvCore::ChannelType channel_type; std::array device_syncpoints{}; + + static std::deque syncpts_accumulated; }; }; // namespace Devices } // namespace Service::Nvidia diff --git a/src/core/hle/service/nvdrv/nvdata.h b/src/core/hle/service/nvdrv/nvdata.h index 0e2f47075..2ee91f9c4 100755 --- a/src/core/hle/service/nvdrv/nvdata.h +++ b/src/core/hle/service/nvdrv/nvdata.h @@ -1,6 +1,7 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-FileCopyrightText: 2021 Skyline Team and Contributors -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2021 yuzu emulator team and Skyline Team and Contributors +// (https://github.com/skyline-emu/) +// SPDX-License-Identifier: GPL-3.0-or-later Licensed under GPLv3 +// or any later version Refer to the license.txt file included. #pragma once diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index 7929443d2..20bf24ec8 100755 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp @@ -1,6 +1,7 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-FileCopyrightText: 2021 Skyline Team and Contributors -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2021 yuzu emulator team and Skyline Team and Contributors +// (https://github.com/skyline-emu/) +// SPDX-License-Identifier: GPL-3.0-or-later Licensed under GPLv3 +// or any later version Refer to the license.txt file included. #include diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index a2aeb80b4..22836529d 100755 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h @@ -1,6 +1,7 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-FileCopyrightText: 2021 Skyline Team and Contributors -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2021 yuzu emulator team and Skyline Team and Contributors +// (https://github.com/skyline-emu/) +// SPDX-License-Identifier: GPL-3.0-or-later Licensed under GPLv3 +// or any later version Refer to the license.txt file included. #pragma once diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.cpp b/src/core/hle/service/nvdrv/nvdrv_interface.cpp index edbdfee43..5e50a04e8 100755 --- a/src/core/hle/service/nvdrv/nvdrv_interface.cpp +++ b/src/core/hle/service/nvdrv/nvdrv_interface.cpp @@ -1,6 +1,7 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-FileCopyrightText: 2021 Skyline Team and Contributors -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2021 yuzu emulator team and Skyline Team and Contributors +// (https://github.com/skyline-emu/) +// SPDX-License-Identifier: GPL-3.0-or-later Licensed under GPLv3 +// or any later version Refer to the license.txt file included. #include #include "common/logging/log.h" diff --git a/src/video_core/control/channel_state.cpp b/src/video_core/control/channel_state.cpp index b04922ac0..3613c4992 100755 --- a/src/video_core/control/channel_state.cpp +++ b/src/video_core/control/channel_state.cpp @@ -1,5 +1,6 @@ -// SPDX-FileCopyrightText: 2022 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv3 or any later version +// Refer to the license.txt file included. #include "common/assert.h" #include "video_core/control/channel_state.h" diff --git a/src/video_core/control/channel_state.h b/src/video_core/control/channel_state.h index 305b21cba..08a7591e1 100755 --- a/src/video_core/control/channel_state.h +++ b/src/video_core/control/channel_state.h @@ -1,5 +1,6 @@ -// SPDX-FileCopyrightText: 2022 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv3 or any later version +// Refer to the license.txt file included. #pragma once diff --git a/src/video_core/control/channel_state_cache.cpp b/src/video_core/control/channel_state_cache.cpp index 4ebeb6356..ec7ba907c 100755 --- a/src/video_core/control/channel_state_cache.cpp +++ b/src/video_core/control/channel_state_cache.cpp @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: 2022 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - #include "video_core/control/channel_state_cache.inc" namespace VideoCommon { diff --git a/src/video_core/control/channel_state_cache.h b/src/video_core/control/channel_state_cache.h index 5246192a8..102947adb 100755 --- a/src/video_core/control/channel_state_cache.h +++ b/src/video_core/control/channel_state_cache.h @@ -1,5 +1,6 @@ -// SPDX-FileCopyrightText: 2022 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv3 or any later version +// Refer to the license.txt file included. #pragma once diff --git a/src/video_core/control/channel_state_cache.inc b/src/video_core/control/channel_state_cache.inc index 460313893..d3ae758b2 100755 --- a/src/video_core/control/channel_state_cache.inc +++ b/src/video_core/control/channel_state_cache.inc @@ -1,5 +1,3 @@ -// SPDX-FileCopyrightText: 2022 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later #include diff --git a/src/video_core/control/scheduler.cpp b/src/video_core/control/scheduler.cpp index 733042690..a9bb00aa7 100755 --- a/src/video_core/control/scheduler.cpp +++ b/src/video_core/control/scheduler.cpp @@ -1,5 +1,6 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv3 or any later version +// Refer to the license.txt file included. #include diff --git a/src/video_core/control/scheduler.h b/src/video_core/control/scheduler.h index 305a01e0a..c1a773946 100755 --- a/src/video_core/control/scheduler.h +++ b/src/video_core/control/scheduler.h @@ -1,5 +1,6 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv3 or any later version +// Refer to the license.txt file included. #pragma once diff --git a/src/video_core/engines/puller.cpp b/src/video_core/engines/puller.cpp index 0df3302e9..c3ed11c13 100755 --- a/src/video_core/engines/puller.cpp +++ b/src/video_core/engines/puller.cpp @@ -1,5 +1,6 @@ -// SPDX-FileCopyrightText: 2022 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. #include "common/assert.h" #include "common/logging/log.h" @@ -73,21 +74,13 @@ void Puller::ProcessSemaphoreTriggerMethod() { const auto op = static_cast(regs.semaphore_trigger & semaphoreOperationMask); if (op == GpuSemaphoreOperation::WriteLong) { - struct Block { - u32 sequence; - u32 zeros = 0; - u64 timestamp; - }; - const GPUVAddr sequence_address{regs.semaphore_address.SemaphoreAddress()}; const u32 payload = regs.semaphore_sequence; std::function operation([this, sequence_address, payload] { - Block block{}; - block.sequence = payload; - block.timestamp = gpu.GetTicks(); - memory_manager.WriteBlockUnsafe(sequence_address, &block, sizeof(block)); + memory_manager.Write(sequence_address + sizeof(u64), gpu.GetTicks()); + memory_manager.Write(sequence_address, payload); }); - rasterizer->SyncOperation(std::move(operation)); + rasterizer->SignalFence(std::move(operation)); } else { do { const u32 word{memory_manager.Read(regs.semaphore_address.SemaphoreAddress())}; diff --git a/src/video_core/engines/puller.h b/src/video_core/engines/puller.h index d4175ee94..b4619e9a8 100755 --- a/src/video_core/engines/puller.h +++ b/src/video_core/engines/puller.h @@ -1,5 +1,6 @@ -// SPDX-FileCopyrightText: 2022 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. #pragma once diff --git a/src/video_core/host1x/control.cpp b/src/video_core/host1x/control.cpp index dceefdb7f..a81c635ae 100755 --- a/src/video_core/host1x/control.cpp +++ b/src/video_core/host1x/control.cpp @@ -1,5 +1,6 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright 2022 yuzu Emulator Project +// Licensed under GPLv3 or any later version +// Refer to the license.txt file included. #include "common/assert.h" #include "video_core/host1x/control.h" diff --git a/src/video_core/host1x/control.h b/src/video_core/host1x/control.h index e117888a3..18a9b56c0 100755 --- a/src/video_core/host1x/control.h +++ b/src/video_core/host1x/control.h @@ -1,6 +1,7 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-FileCopyrightText: 2021 Skyline Team and Contributors -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2021 yuzu emulator team and Skyline Team and Contributors +// (https://github.com/skyline-emu/) +// SPDX-License-Identifier: GPL-3.0-or-later Licensed under GPLv3 +// or any later version Refer to the license.txt file included. #pragma once diff --git a/src/video_core/host1x/host1x.cpp b/src/video_core/host1x/host1x.cpp index 7c317a85d..eb00f4855 100755 --- a/src/video_core/host1x/host1x.cpp +++ b/src/video_core/host1x/host1x.cpp @@ -1,5 +1,6 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright 2022 yuzu Emulator Project +// Licensed under GPLv3 or any later version +// Refer to the license.txt file included. #include "core/core.h" #include "video_core/host1x/host1x.h" diff --git a/src/video_core/host1x/host1x.h b/src/video_core/host1x/host1x.h index 7ecf853d9..e4b69d75a 100755 --- a/src/video_core/host1x/host1x.h +++ b/src/video_core/host1x/host1x.h @@ -1,5 +1,6 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright 2022 yuzu Emulator Project +// Licensed under GPLv3 or any later version +// Refer to the license.txt file included. #pragma once diff --git a/src/video_core/host1x/syncpoint_manager.cpp b/src/video_core/host1x/syncpoint_manager.cpp index 4471bacae..825bd551e 100755 --- a/src/video_core/host1x/syncpoint_manager.cpp +++ b/src/video_core/host1x/syncpoint_manager.cpp @@ -1,5 +1,6 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv3 or any later version +// Refer to the license.txt file included. #include "common/microprofile.h" #include "video_core/host1x/syncpoint_manager.h" diff --git a/src/video_core/host1x/syncpoint_manager.h b/src/video_core/host1x/syncpoint_manager.h index 72220a09a..440b1508a 100755 --- a/src/video_core/host1x/syncpoint_manager.h +++ b/src/video_core/host1x/syncpoint_manager.h @@ -1,5 +1,6 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv3 or any later version +// Refer to the license.txt file included. #pragma once diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index f5ee9ad62..152c79e8a 100755 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -1475,7 +1475,7 @@ bool Image::BlitScaleHelper(bool scale_up) { }; const VkExtent2D extent{ .width = std::max(scaled_width, info.size.width), - .height = std::max(scaled_height, info.size.width), + .height = std::max(scaled_height, info.size.height), }; auto* view_ptr = blit_view.get(); @@ -1772,7 +1772,6 @@ void Framebuffer::CreateFramebuffer(TextureCacheRuntime& runtime, s32 num_layers = 1; const auto& resolution = runtime.resolution; - is_rescaled |= resolution.active; u32 width = 0; u32 height = 0; diff --git a/src/video_core/texture_cache/texture_cache.cpp b/src/video_core/texture_cache/texture_cache.cpp index 8a9a32f44..bc905a1a4 100755 --- a/src/video_core/texture_cache/texture_cache.cpp +++ b/src/video_core/texture_cache/texture_cache.cpp @@ -1,5 +1,6 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv3 or any later version +// Refer to the license.txt file included. #include "video_core/control/channel_state_cache.inc" #include "video_core/texture_cache/texture_cache_base.h" diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 88a61aa41..ae8766f89 100755 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -1,5 +1,7 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2021 yuzu emulator team +// (https://github.com/skyline-emu/) +// SPDX-License-Identifier: GPL-3.0-or-later Licensed under GPLv3 +// or any later version Refer to the license.txt file included. #pragma once @@ -355,6 +357,7 @@ void TextureCache

::UpdateRenderTargets(bool is_clear) { (maxwell3d->regs.render_area.width * up_scale) >> down_shift, (maxwell3d->regs.render_area.height * up_scale) >> down_shift, }; + render_targets.is_rescaled = is_rescaling; flags[Dirty::DepthBiasGlobal] = true; } diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index c6790abc0..e8eed022e 100755 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h @@ -1,5 +1,7 @@ -// SPDX-FileCopyrightText: 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2021 yuzu emulator team +// (https://github.com/skyline-emu/) +// SPDX-License-Identifier: GPL-3.0-or-later Licensed under GPLv3 +// or any later version Refer to the license.txt file included. #pragma once