Memory: apply rasterizer cache mark to all page tables and the global marker

This commit is contained in:
Weiyi Wang 2018-12-10 22:21:03 -05:00
parent 88161b8ac6
commit bf2056f12e

View file

@ -375,37 +375,40 @@ void MemorySystem::RasterizerMarkRegionCached(PAddr start, u32 size, bool cached
for (unsigned i = 0; i < num_pages; ++i, paddr += PAGE_SIZE) { for (unsigned i = 0; i < num_pages; ++i, paddr += PAGE_SIZE) {
for (VAddr vaddr : PhysicalToVirtualAddressForRasterizer(paddr)) { for (VAddr vaddr : PhysicalToVirtualAddressForRasterizer(paddr)) {
PageType& page_type = impl->current_page_table->attributes[vaddr >> PAGE_BITS]; impl->cache_marker.Mark(vaddr, cached);
for (PageTable* page_table : impl->page_table_list) {
PageType& page_type = page_table->attributes[vaddr >> PAGE_BITS];
if (cached) { if (cached) {
// Switch page type to cached if now cached // Switch page type to cached if now cached
switch (page_type) { switch (page_type) {
case PageType::Unmapped: case PageType::Unmapped:
// It is not necessary for a process to have this region mapped into its address // It is not necessary for a process to have this region mapped into its
// space, for example, a system module need not have a VRAM mapping. // address space, for example, a system module need not have a VRAM mapping.
break; break;
case PageType::Memory: case PageType::Memory:
page_type = PageType::RasterizerCachedMemory; page_type = PageType::RasterizerCachedMemory;
impl->current_page_table->pointers[vaddr >> PAGE_BITS] = nullptr; page_table->pointers[vaddr >> PAGE_BITS] = nullptr;
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} else { } else {
// Switch page type to uncached if now uncached // Switch page type to uncached if now uncached
switch (page_type) { switch (page_type) {
case PageType::Unmapped: case PageType::Unmapped:
// It is not necessary for a process to have this region mapped into its address // It is not necessary for a process to have this region mapped into its
// space, for example, a system module need not have a VRAM mapping. // address space, for example, a system module need not have a VRAM mapping.
break; break;
case PageType::RasterizerCachedMemory: { case PageType::RasterizerCachedMemory: {
page_type = PageType::Memory; page_type = PageType::Memory;
impl->current_page_table->pointers[vaddr >> PAGE_BITS] = page_table->pointers[vaddr >> PAGE_BITS] =
GetPointerForRasterizerCache(vaddr & ~PAGE_MASK); GetPointerForRasterizerCache(vaddr & ~PAGE_MASK);
break; break;
} }
default: default:
UNREACHABLE(); UNREACHABLE();
}
} }
} }
} }