diff options
author | bunnei <bunneidev@gmail.com> | 2021-08-07 02:46:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-07 02:46:46 +0200 |
commit | f183668a872bc127da3f605a44e2f33174b3294e (patch) | |
tree | 9ef9f561b3001e5241d4bccf90591f4caab2f2dd /src/core/hle | |
parent | Merge pull request #6822 from yzct12345/clion-assert (diff) | |
parent | nvhost_nvdec_common: Remove BufferMap (diff) | |
download | yuzu-f183668a872bc127da3f605a44e2f33174b3294e.tar yuzu-f183668a872bc127da3f605a44e2f33174b3294e.tar.gz yuzu-f183668a872bc127da3f605a44e2f33174b3294e.tar.bz2 yuzu-f183668a872bc127da3f605a44e2f33174b3294e.tar.lz yuzu-f183668a872bc127da3f605a44e2f33174b3294e.tar.xz yuzu-f183668a872bc127da3f605a44e2f33174b3294e.tar.zst yuzu-f183668a872bc127da3f605a44e2f33174b3294e.zip |
Diffstat (limited to 'src/core/hle')
-rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp | 58 | ||||
-rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h | 45 |
2 files changed, 4 insertions, 99 deletions
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 1403a39d0..845de724d 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp @@ -166,8 +166,6 @@ NvResult nvhost_nvdec_common::MapBuffer(const std::vector<u8>& input, std::vecto LOG_ERROR(Service_NVDRV, "failed to map size={}", object->size); } else { cmd_buffer.map_address = object->dma_map_addr; - AddBufferMap(object->dma_map_addr, object->size, object->addr, - object->status == nvmap::Object::Status::Allocated); } } std::memcpy(output.data(), ¶ms, sizeof(IoctlMapBuffer)); @@ -178,30 +176,11 @@ NvResult nvhost_nvdec_common::MapBuffer(const std::vector<u8>& input, std::vecto } NvResult nvhost_nvdec_common::UnmapBuffer(const std::vector<u8>& input, std::vector<u8>& output) { - IoctlMapBuffer params{}; - std::memcpy(¶ms, input.data(), sizeof(IoctlMapBuffer)); - std::vector<MapBufferEntry> cmd_buffer_handles(params.num_entries); - SliceVectors(input, cmd_buffer_handles, params.num_entries, sizeof(IoctlMapBuffer)); - - auto& gpu = system.GPU(); - - for (auto& cmd_buffer : cmd_buffer_handles) { - const auto object{nvmap_dev->GetObject(cmd_buffer.map_handle)}; - if (!object) { - LOG_ERROR(Service_NVDRV, "invalid cmd_buffer nvmap_handle={:X}", cmd_buffer.map_handle); - std::memcpy(output.data(), ¶ms, output.size()); - return NvResult::InvalidState; - } - if (const auto size{RemoveBufferMap(object->dma_map_addr)}; size) { - gpu.MemoryManager().Unmap(object->dma_map_addr, *size); - } else { - // This occurs quite frequently, however does not seem to impact functionality - LOG_DEBUG(Service_NVDRV, "invalid offset=0x{:X} dma=0x{:X}", object->addr, - object->dma_map_addr); - } - object->dma_map_addr = 0; - } + // This is intntionally stubbed. + // Skip unmapping buffers here, as to not break the continuity of the VP9 reference frame + // addresses, and risk invalidating data before the async GPU thread is done with it std::memset(output.data(), 0, output.size()); + LOG_DEBUG(Service_NVDRV, "(STUBBED) called"); return NvResult::Success; } @@ -212,33 +191,4 @@ NvResult nvhost_nvdec_common::SetSubmitTimeout(const std::vector<u8>& input, return NvResult::Success; } -std::optional<nvhost_nvdec_common::BufferMap> nvhost_nvdec_common::FindBufferMap( - GPUVAddr gpu_addr) const { - const auto it = std::find_if( - buffer_mappings.begin(), buffer_mappings.upper_bound(gpu_addr), [&](const auto& entry) { - return (gpu_addr >= entry.second.StartAddr() && gpu_addr < entry.second.EndAddr()); - }); - - ASSERT(it != buffer_mappings.end()); - return it->second; -} - -void nvhost_nvdec_common::AddBufferMap(GPUVAddr gpu_addr, std::size_t size, VAddr cpu_addr, - bool is_allocated) { - buffer_mappings.insert_or_assign(gpu_addr, BufferMap{gpu_addr, size, cpu_addr, is_allocated}); -} - -std::optional<std::size_t> nvhost_nvdec_common::RemoveBufferMap(GPUVAddr gpu_addr) { - const auto iter{buffer_mappings.find(gpu_addr)}; - if (iter == buffer_mappings.end()) { - return std::nullopt; - } - std::size_t size = 0; - if (iter->second.IsAllocated()) { - size = iter->second.Size(); - } - buffer_mappings.erase(iter); - return size; -} - } // namespace Service::Nvidia::Devices 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 da10f5f41..af59f00d2 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h @@ -23,45 +23,6 @@ public: ~nvhost_nvdec_common() override; protected: - class BufferMap final { - public: - constexpr BufferMap() = default; - - constexpr BufferMap(GPUVAddr start_addr_, std::size_t size_) - : start_addr{start_addr_}, end_addr{start_addr_ + size_} {} - - constexpr BufferMap(GPUVAddr start_addr_, std::size_t size_, VAddr cpu_addr_, - bool is_allocated_) - : start_addr{start_addr_}, end_addr{start_addr_ + size_}, cpu_addr{cpu_addr_}, - is_allocated{is_allocated_} {} - - constexpr VAddr StartAddr() const { - return start_addr; - } - - constexpr VAddr EndAddr() const { - return end_addr; - } - - constexpr std::size_t Size() const { - return end_addr - start_addr; - } - - constexpr VAddr CpuAddr() const { - return cpu_addr; - } - - constexpr bool IsAllocated() const { - return is_allocated; - } - - private: - GPUVAddr start_addr{}; - GPUVAddr end_addr{}; - VAddr cpu_addr{}; - bool is_allocated{}; - }; - struct IoctlSetNvmapFD { s32_le nvmap_fd{}; }; @@ -154,17 +115,11 @@ protected: NvResult UnmapBuffer(const std::vector<u8>& input, std::vector<u8>& output); NvResult SetSubmitTimeout(const std::vector<u8>& input, std::vector<u8>& output); - std::optional<BufferMap> FindBufferMap(GPUVAddr gpu_addr) const; - void AddBufferMap(GPUVAddr gpu_addr, std::size_t size, VAddr cpu_addr, bool is_allocated); - std::optional<std::size_t> RemoveBufferMap(GPUVAddr gpu_addr); - s32_le nvmap_fd{}; u32_le submit_timeout{}; std::shared_ptr<nvmap> nvmap_dev; SyncpointManager& syncpoint_manager; std::array<u32, MaxSyncPoints> device_syncpoints{}; - // This is expected to be ordered, therefore we must use a map, not unordered_map - std::map<GPUVAddr, BufferMap> buffer_mappings; }; }; // namespace Devices } // namespace Service::Nvidia |