diff options
author | bunnei <bunneidev@gmail.com> | 2018-06-24 23:42:29 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2018-06-27 06:08:03 +0200 |
commit | 3f9f047375dd9aae7eadcb957747fa8db01544bf (patch) | |
tree | 4a5ce82d2726e5f723a3a7a0e72d973f6d6d0573 /src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |
parent | gl_rasterizer_cache: Cache size_in_bytes as a const per surface. (diff) | |
download | yuzu-3f9f047375dd9aae7eadcb957747fa8db01544bf.tar yuzu-3f9f047375dd9aae7eadcb957747fa8db01544bf.tar.gz yuzu-3f9f047375dd9aae7eadcb957747fa8db01544bf.tar.bz2 yuzu-3f9f047375dd9aae7eadcb957747fa8db01544bf.tar.lz yuzu-3f9f047375dd9aae7eadcb957747fa8db01544bf.tar.xz yuzu-3f9f047375dd9aae7eadcb957747fa8db01544bf.tar.zst yuzu-3f9f047375dd9aae7eadcb957747fa8db01544bf.zip |
Diffstat (limited to 'src/video_core/renderer_opengl/gl_rasterizer_cache.cpp')
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 882490f47..919931d64 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -436,3 +436,29 @@ Surface RasterizerCacheOpenGL::GetSurface(const SurfaceParams& params) { return surface; } + +Surface RasterizerCacheOpenGL::TryFindFramebufferSurface(VAddr cpu_addr) const { + // Tries to find the GPU address of a framebuffer based on the CPU address. This is because + // final output framebuffers are specified by CPU address, but internally our GPU cache uses GPU + // addresses. We iterate through all cached framebuffers, and compare their starting CPU address + // to the one provided. This is obviously not great, and won't work if the framebuffer overlaps + // surfaces. + + std::vector<Surface> surfaces; + for (const auto& surface : surface_cache) { + const auto& params = surface.second->GetSurfaceParams(); + const VAddr surface_cpu_addr = params.GetCpuAddr(); + if (cpu_addr >= surface_cpu_addr && cpu_addr < (surface_cpu_addr + params.size_in_bytes)) { + ASSERT_MSG(cpu_addr == surface_cpu_addr, "overlapping surfaces are unsupported"); + surfaces.push_back(surface.second); + } + } + + if (surfaces.empty()) { + return {}; + } + + ASSERT_MSG(surfaces.size() == 1, ">1 surface is unsupported"); + + return surfaces[0]; +} |