diff options
| author | 2022-12-10 12:24:33 -0500 | |
|---|---|---|
| committer | 2022-12-11 12:46:34 -0500 | |
| commit | ed3719244111af380fbba9e13286192c00708dea (patch) | |
| tree | 717f9598dd33fef8783005c9015486bc88a8a6c2 /src/core/memory.cpp | |
| parent | Merge pull request #9412 from Saalvage/fix/trace-log-compilation (diff) | |
| download | yuzu-ed3719244111af380fbba9e13286192c00708dea.tar.gz yuzu-ed3719244111af380fbba9e13286192c00708dea.tar.xz yuzu-ed3719244111af380fbba9e13286192c00708dea.zip | |
memory: correct semantics of data cache management operations
Diffstat (limited to 'src/core/memory.cpp')
| -rw-r--r-- | src/core/memory.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 3141122f1..b24716455 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #include "common/assert.h" | 7 | #include "common/assert.h" |
| 8 | #include "common/atomic_ops.h" | 8 | #include "common/atomic_ops.h" |
| 9 | #include "common/cache_management.h" | ||
| 10 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 11 | #include "common/logging/log.h" | 10 | #include "common/logging/log.h" |
| 12 | #include "common/page_table.h" | 11 | #include "common/page_table.h" |
| @@ -342,10 +341,9 @@ struct Memory::Impl { | |||
| 342 | LOG_ERROR(HW_Memory, "Unmapped cache maintenance @ {:#018X}", current_vaddr); | 341 | LOG_ERROR(HW_Memory, "Unmapped cache maintenance @ {:#018X}", current_vaddr); |
| 343 | throw InvalidMemoryException(); | 342 | throw InvalidMemoryException(); |
| 344 | }, | 343 | }, |
| 345 | [&](const std::size_t block_size, u8* const host_ptr) { cb(block_size, host_ptr); }, | 344 | [&](const std::size_t block_size, u8* const host_ptr) {}, |
| 346 | [&](const VAddr current_vaddr, const std::size_t block_size, u8* const host_ptr) { | 345 | [&](const VAddr current_vaddr, const std::size_t block_size, u8* const host_ptr) { |
| 347 | system.GPU().FlushRegion(current_vaddr, block_size); | 346 | cb(current_vaddr, block_size); |
| 348 | cb(block_size, host_ptr); | ||
| 349 | }, | 347 | }, |
| 350 | [](const std::size_t block_size) {}); | 348 | [](const std::size_t block_size) {}); |
| 351 | } catch (InvalidMemoryException&) { | 349 | } catch (InvalidMemoryException&) { |
| @@ -356,27 +354,30 @@ struct Memory::Impl { | |||
| 356 | } | 354 | } |
| 357 | 355 | ||
| 358 | Result InvalidateDataCache(const Kernel::KProcess& process, VAddr dest_addr, std::size_t size) { | 356 | Result InvalidateDataCache(const Kernel::KProcess& process, VAddr dest_addr, std::size_t size) { |
| 359 | auto perform = [&](const std::size_t block_size, u8* const host_ptr) { | 357 | auto on_rasterizer = [&](const VAddr current_vaddr, const std::size_t block_size) { |
| 360 | // Do nothing; this operation (dc ivac) cannot be supported | 358 | // dc ivac: Invalidate to point of coherency |
| 361 | // from EL0 | 359 | // GPU flush -> CPU invalidate |
| 360 | system.GPU().FlushRegion(current_vaddr, block_size); | ||
| 362 | }; | 361 | }; |
| 363 | return PerformCacheOperation(process, dest_addr, size, perform); | 362 | return PerformCacheOperation(process, dest_addr, size, on_rasterizer); |
| 364 | } | 363 | } |
| 365 | 364 | ||
| 366 | Result StoreDataCache(const Kernel::KProcess& process, VAddr dest_addr, std::size_t size) { | 365 | Result StoreDataCache(const Kernel::KProcess& process, VAddr dest_addr, std::size_t size) { |
| 367 | auto perform = [&](const std::size_t block_size, u8* const host_ptr) { | 366 | auto on_rasterizer = [&](const VAddr current_vaddr, const std::size_t block_size) { |
| 368 | // dc cvac: Store to point of coherency | 367 | // dc cvac: Store to point of coherency |
| 369 | Common::DataCacheLineCleanByVAToPoC(host_ptr, block_size); | 368 | // CPU flush -> GPU invalidate |
| 369 | system.GPU().InvalidateRegion(current_vaddr, block_size); | ||
| 370 | }; | 370 | }; |
| 371 | return PerformCacheOperation(process, dest_addr, size, perform); | 371 | return PerformCacheOperation(process, dest_addr, size, on_rasterizer); |
| 372 | } | 372 | } |
| 373 | 373 | ||
| 374 | Result FlushDataCache(const Kernel::KProcess& process, VAddr dest_addr, std::size_t size) { | 374 | Result FlushDataCache(const Kernel::KProcess& process, VAddr dest_addr, std::size_t size) { |
| 375 | auto perform = [&](const std::size_t block_size, u8* const host_ptr) { | 375 | auto on_rasterizer = [&](const VAddr current_vaddr, const std::size_t block_size) { |
| 376 | // dc civac: Store to point of coherency, and invalidate from cache | 376 | // dc civac: Store to point of coherency, and invalidate from cache |
| 377 | Common::DataCacheLineCleanAndInvalidateByVAToPoC(host_ptr, block_size); | 377 | // CPU flush -> GPU invalidate |
| 378 | system.GPU().InvalidateRegion(current_vaddr, block_size); | ||
| 378 | }; | 379 | }; |
| 379 | return PerformCacheOperation(process, dest_addr, size, perform); | 380 | return PerformCacheOperation(process, dest_addr, size, on_rasterizer); |
| 380 | } | 381 | } |
| 381 | 382 | ||
| 382 | void MarkRegionDebug(VAddr vaddr, u64 size, bool debug) { | 383 | void MarkRegionDebug(VAddr vaddr, u64 size, bool debug) { |