diff options
author | bunnei <bunneidev@gmail.com> | 2018-08-28 18:28:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-28 18:28:57 +0200 |
commit | 4d7e1662c84ef65f7da5a27b0473125cc6759d5c (patch) | |
tree | 63c9f3fc7a8a76af35e0b5890a4388a4250318a4 /src/video_core | |
parent | Merge pull request #1192 from lioncash/unused (diff) | |
parent | gpu: Make memory_manager private (diff) | |
download | yuzu-4d7e1662c84ef65f7da5a27b0473125cc6759d5c.tar yuzu-4d7e1662c84ef65f7da5a27b0473125cc6759d5c.tar.gz yuzu-4d7e1662c84ef65f7da5a27b0473125cc6759d5c.tar.bz2 yuzu-4d7e1662c84ef65f7da5a27b0473125cc6759d5c.tar.lz yuzu-4d7e1662c84ef65f7da5a27b0473125cc6759d5c.tar.xz yuzu-4d7e1662c84ef65f7da5a27b0473125cc6759d5c.tar.zst yuzu-4d7e1662c84ef65f7da5a27b0473125cc6759d5c.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/gpu.cpp | 14 | ||||
-rw-r--r-- | src/video_core/gpu.h | 12 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 4 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 16 |
4 files changed, 30 insertions, 16 deletions
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 9758adcfd..e6d8e65c6 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp @@ -22,7 +22,7 @@ u32 FramebufferConfig::BytesPerPixel(PixelFormat format) { } GPU::GPU(VideoCore::RasterizerInterface& rasterizer) { - memory_manager = std::make_unique<MemoryManager>(); + memory_manager = std::make_unique<Tegra::MemoryManager>(); maxwell_3d = std::make_unique<Engines::Maxwell3D>(rasterizer, *memory_manager); fermi_2d = std::make_unique<Engines::Fermi2D>(*memory_manager); maxwell_compute = std::make_unique<Engines::MaxwellCompute>(); @@ -31,14 +31,22 @@ GPU::GPU(VideoCore::RasterizerInterface& rasterizer) { GPU::~GPU() = default; -const Engines::Maxwell3D& GPU::Maxwell3D() const { +Engines::Maxwell3D& GPU::Maxwell3D() { return *maxwell_3d; } -Engines::Maxwell3D& GPU::Maxwell3D() { +const Engines::Maxwell3D& GPU::Maxwell3D() const { return *maxwell_3d; } +MemoryManager& GPU::MemoryManager() { + return *memory_manager; +} + +const MemoryManager& GPU::MemoryManager() const { + return *memory_manager; +} + u32 RenderTargetBytesPerPixel(RenderTargetFormat format) { ASSERT(format != RenderTargetFormat::NONE); diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index 2697e1c27..2c3dbd97b 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h @@ -117,18 +117,24 @@ public: /// Processes a command list stored at the specified address in GPU memory. void ProcessCommandList(GPUVAddr address, u32 size); + /// Returns a reference to the Maxwell3D GPU engine. + Engines::Maxwell3D& Maxwell3D(); + /// Returns a const reference to the Maxwell3D GPU engine. const Engines::Maxwell3D& Maxwell3D() const; - /// Returns a reference to the Maxwell3D GPU engine. - Engines::Maxwell3D& Maxwell3D(); + /// Returns a reference to the GPU memory manager. + Tegra::MemoryManager& MemoryManager(); - std::unique_ptr<MemoryManager> memory_manager; + /// Returns a const reference to the GPU memory manager. + const Tegra::MemoryManager& MemoryManager() const; private: /// Writes a single register in the engine bound to the specified subchannel void WriteReg(u32 method, u32 subchannel, u32 value, u32 remaining_params); + std::unique_ptr<Tegra::MemoryManager> memory_manager; + /// Mapping of command subchannels to their bound engine ids. std::unordered_map<u32, EngineID> bound_engines; diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index dcf987d89..f014183b8 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -424,8 +424,8 @@ std::tuple<u8*, GLintptr, GLintptr> RasterizerOpenGL::UploadMemory(u8* buffer_pt std::tie(buffer_ptr, buffer_offset) = AlignBuffer(buffer_ptr, buffer_offset, alignment); GLintptr uploaded_offset = buffer_offset; - const auto& memory_manager = Core::System::GetInstance().GPU().memory_manager; - const boost::optional<VAddr> cpu_addr{memory_manager->GpuToCpuAddress(gpu_addr)}; + auto& memory_manager = Core::System::GetInstance().GPU().MemoryManager(); + const boost::optional<VAddr> cpu_addr{memory_manager.GpuToCpuAddress(gpu_addr)}; Memory::ReadBlock(*cpu_addr, buffer_ptr, size); buffer_ptr += size; diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 65305000c..d87f90a62 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -168,8 +168,8 @@ static const FormatTuple& GetFormatTuple(PixelFormat pixel_format, ComponentType } VAddr SurfaceParams::GetCpuAddr() const { - const auto& gpu = Core::System::GetInstance().GPU(); - return *gpu.memory_manager->GpuToCpuAddress(addr); + auto& gpu = Core::System::GetInstance().GPU(); + return *gpu.MemoryManager().GpuToCpuAddress(addr); } static bool IsPixelFormatASTC(PixelFormat format) { @@ -220,14 +220,14 @@ void MortonCopy(u32 stride, u32 block_height, u32 height, std::vector<u8>& gl_bu Tegra::GPUVAddr addr) { constexpr u32 bytes_per_pixel = SurfaceParams::GetFormatBpp(format) / CHAR_BIT; constexpr u32 gl_bytes_per_pixel = CachedSurface::GetGLBytesPerPixel(format); - const auto& gpu = Core::System::GetInstance().GPU(); + auto& gpu = Core::System::GetInstance().GPU(); if (morton_to_gl) { // With the BCn formats (DXT and DXN), each 4x4 tile is swizzled instead of just individual // pixel values. const u32 tile_size{IsFormatBCn(format) ? 4U : 1U}; const std::vector<u8> data = - Tegra::Texture::UnswizzleTexture(*gpu.memory_manager->GpuToCpuAddress(addr), tile_size, + Tegra::Texture::UnswizzleTexture(*gpu.MemoryManager().GpuToCpuAddress(addr), tile_size, bytes_per_pixel, stride, height, block_height); const size_t size_to_copy{std::min(gl_buffer.size(), data.size())}; gl_buffer.assign(data.begin(), data.begin() + size_to_copy); @@ -237,7 +237,7 @@ void MortonCopy(u32 stride, u32 block_height, u32 height, std::vector<u8>& gl_bu LOG_WARNING(Render_OpenGL, "need to use correct swizzle/GOB parameters!"); VideoCore::MortonCopyPixels128( stride, height, bytes_per_pixel, gl_bytes_per_pixel, - Memory::GetPointer(*gpu.memory_manager->GpuToCpuAddress(addr)), gl_buffer.data(), + Memory::GetPointer(*gpu.MemoryManager().GpuToCpuAddress(addr)), gl_buffer.data(), morton_to_gl); } } @@ -754,9 +754,9 @@ Surface RasterizerCacheOpenGL::GetSurface(const SurfaceParams& params, bool pres return {}; } - const auto& gpu = Core::System::GetInstance().GPU(); + auto& gpu = Core::System::GetInstance().GPU(); // Don't try to create any entries in the cache if the address of the texture is invalid. - if (gpu.memory_manager->GpuToCpuAddress(params.addr) == boost::none) + if (gpu.MemoryManager().GpuToCpuAddress(params.addr) == boost::none) return {}; // Look up surface in the cache based on address @@ -848,7 +848,7 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& surface, "reinterpretation but the texture is tiled."); } size_t remaining_size = new_params.SizeInBytes() - params.SizeInBytes(); - auto address = Core::System::GetInstance().GPU().memory_manager->GpuToCpuAddress( + auto address = Core::System::GetInstance().GPU().MemoryManager().GpuToCpuAddress( new_params.addr + params.SizeInBytes()); std::vector<u8> data(remaining_size); Memory::ReadBlock(*address, data.data(), data.size()); |