1
0
Fork 0
forked from suyu/suyu

prefer system reference over global accessor

This commit is contained in:
Michael Scire 2019-07-08 23:17:44 -07:00
parent 697206092e
commit a1845d1dd3
3 changed files with 13 additions and 9 deletions

View file

@ -31,7 +31,7 @@ u32 FramebufferConfig::BytesPerPixel(PixelFormat format) {
GPU::GPU(Core::System& system, VideoCore::RendererBase& renderer) : renderer{renderer} { GPU::GPU(Core::System& system, VideoCore::RendererBase& renderer) : renderer{renderer} {
auto& rasterizer{renderer.Rasterizer()}; auto& rasterizer{renderer.Rasterizer()};
memory_manager = std::make_unique<Tegra::MemoryManager>(rasterizer); memory_manager = std::make_unique<Tegra::MemoryManager>(system, rasterizer);
dma_pusher = std::make_unique<Tegra::DmaPusher>(*this); dma_pusher = std::make_unique<Tegra::DmaPusher>(*this);
maxwell_3d = std::make_unique<Engines::Maxwell3D>(system, rasterizer, *memory_manager); maxwell_3d = std::make_unique<Engines::Maxwell3D>(system, rasterizer, *memory_manager);
fermi_2d = std::make_unique<Engines::Fermi2D>(rasterizer, *memory_manager); fermi_2d = std::make_unique<Engines::Fermi2D>(rasterizer, *memory_manager);

View file

@ -14,7 +14,8 @@
namespace Tegra { namespace Tegra {
MemoryManager::MemoryManager(VideoCore::RasterizerInterface& rasterizer) : rasterizer{rasterizer} { MemoryManager::MemoryManager(Core::System& system, VideoCore::RasterizerInterface& rasterizer)
: rasterizer{rasterizer}, system{system} {
std::fill(page_table.pointers.begin(), page_table.pointers.end(), nullptr); std::fill(page_table.pointers.begin(), page_table.pointers.end(), nullptr);
std::fill(page_table.attributes.begin(), page_table.attributes.end(), std::fill(page_table.attributes.begin(), page_table.attributes.end(),
Common::PageType::Unmapped); Common::PageType::Unmapped);
@ -52,8 +53,7 @@ GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, u64 size) {
const GPUVAddr gpu_addr{FindFreeRegion(address_space_base, aligned_size)}; const GPUVAddr gpu_addr{FindFreeRegion(address_space_base, aligned_size)};
MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), aligned_size, cpu_addr); MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), aligned_size, cpu_addr);
ASSERT(Core::System::GetInstance() ASSERT(system.CurrentProcess()
.CurrentProcess()
->VMManager() ->VMManager()
.SetMemoryAttribute(cpu_addr, size, Kernel::MemoryAttribute::DeviceMapped, .SetMemoryAttribute(cpu_addr, size, Kernel::MemoryAttribute::DeviceMapped,
Kernel::MemoryAttribute::DeviceMapped) Kernel::MemoryAttribute::DeviceMapped)
@ -68,8 +68,7 @@ GPUVAddr MemoryManager::MapBufferEx(VAddr cpu_addr, GPUVAddr gpu_addr, u64 size)
const u64 aligned_size{Common::AlignUp(size, page_size)}; const u64 aligned_size{Common::AlignUp(size, page_size)};
MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), aligned_size, cpu_addr); MapBackingMemory(gpu_addr, Memory::GetPointer(cpu_addr), aligned_size, cpu_addr);
ASSERT(Core::System::GetInstance() ASSERT(system.CurrentProcess()
.CurrentProcess()
->VMManager() ->VMManager()
.SetMemoryAttribute(cpu_addr, size, Kernel::MemoryAttribute::DeviceMapped, .SetMemoryAttribute(cpu_addr, size, Kernel::MemoryAttribute::DeviceMapped,
Kernel::MemoryAttribute::DeviceMapped) Kernel::MemoryAttribute::DeviceMapped)
@ -87,8 +86,7 @@ GPUVAddr MemoryManager::UnmapBuffer(GPUVAddr gpu_addr, u64 size) {
rasterizer.FlushAndInvalidateRegion(cache_addr, aligned_size); rasterizer.FlushAndInvalidateRegion(cache_addr, aligned_size);
UnmapRange(gpu_addr, aligned_size); UnmapRange(gpu_addr, aligned_size);
ASSERT(Core::System::GetInstance() ASSERT(system.CurrentProcess()
.CurrentProcess()
->VMManager() ->VMManager()
.SetMemoryAttribute(cpu_addr.value(), size, Kernel::MemoryAttribute::DeviceMapped, .SetMemoryAttribute(cpu_addr.value(), size, Kernel::MemoryAttribute::DeviceMapped,
Kernel::MemoryAttribute::None) Kernel::MemoryAttribute::None)

View file

@ -14,6 +14,10 @@ namespace VideoCore {
class RasterizerInterface; class RasterizerInterface;
} }
namespace Core {
class System;
}
namespace Tegra { namespace Tegra {
/** /**
@ -47,7 +51,7 @@ struct VirtualMemoryArea {
class MemoryManager final { class MemoryManager final {
public: public:
explicit MemoryManager(VideoCore::RasterizerInterface& rasterizer); explicit MemoryManager(Core::System& system, VideoCore::RasterizerInterface& rasterizer);
~MemoryManager(); ~MemoryManager();
GPUVAddr AllocateSpace(u64 size, u64 align); GPUVAddr AllocateSpace(u64 size, u64 align);
@ -173,6 +177,8 @@ private:
Common::PageTable page_table{page_bits}; Common::PageTable page_table{page_bits};
VMAMap vma_map; VMAMap vma_map;
VideoCore::RasterizerInterface& rasterizer; VideoCore::RasterizerInterface& rasterizer;
Core::System& system;
}; };
} // namespace Tegra } // namespace Tegra