diff options
| author | 2018-04-24 00:46:51 -0400 | |
|---|---|---|
| committer | 2018-04-24 22:31:46 -0400 | |
| commit | fbb3cd110c598003bf58a2aca5be489b5f3fb772 (patch) | |
| tree | 570d425c25583a3609d719e3b5f495a5dbbf00b1 /src | |
| parent | gl_rasterizer_cache: Handle compressed texture sizes. (diff) | |
| download | yuzu-fbb3cd110c598003bf58a2aca5be489b5f3fb772.tar.gz yuzu-fbb3cd110c598003bf58a2aca5be489b5f3fb772.tar.xz yuzu-fbb3cd110c598003bf58a2aca5be489b5f3fb772.zip | |
gl_rasterizer_cache: Add a function for finding framebuffer GPU address.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 27 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 3 |
3 files changed, 31 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index bc9368877..b457b1fbe 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -560,6 +560,7 @@ bool RasterizerOpenGL::AccelerateDisplay(const Tegra::FramebufferConfig& framebu | |||
| 560 | 560 | ||
| 561 | SurfaceParams src_params; | 561 | SurfaceParams src_params; |
| 562 | src_params.cpu_addr = framebuffer_addr; | 562 | src_params.cpu_addr = framebuffer_addr; |
| 563 | src_params.addr = res_cache.TryFindFramebufferGpuAddress(framebuffer_addr).get_value_or(0); | ||
| 563 | src_params.width = std::min(framebuffer.width, pixel_stride); | 564 | src_params.width = std::min(framebuffer.width, pixel_stride); |
| 564 | src_params.height = framebuffer.height; | 565 | src_params.height = framebuffer.height; |
| 565 | src_params.stride = pixel_stride; | 566 | src_params.stride = pixel_stride; |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index e1ad00feb..b924f1b8e 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -954,6 +954,33 @@ Surface RasterizerCacheOpenGL::GetSurface(const SurfaceParams& params, ScaleMatc | |||
| 954 | return surface; | 954 | return surface; |
| 955 | } | 955 | } |
| 956 | 956 | ||
| 957 | boost::optional<Tegra::GPUVAddr> RasterizerCacheOpenGL::TryFindFramebufferGpuAddress( | ||
| 958 | VAddr cpu_addr) const { | ||
| 959 | // Tries to find the GPU address of a framebuffer based on the CPU address. This is because | ||
| 960 | // final output framebuffers are specified by CPU address, but internally our GPU cache uses GPU | ||
| 961 | // addresses. We iterate through all cached framebuffers, and compare their starting CPU address | ||
| 962 | // to the one provided. This is obviously not great, and won't work if the framebuffer overlaps | ||
| 963 | // surfaces. | ||
| 964 | |||
| 965 | std::vector<Tegra::GPUVAddr> gpu_addresses; | ||
| 966 | for (const auto& pair : surface_cache) { | ||
| 967 | for (const auto& surface : pair.second) { | ||
| 968 | const VAddr surface_cpu_addr = surface->GetCpuAddr(); | ||
| 969 | if (cpu_addr >= surface_cpu_addr && cpu_addr < (surface_cpu_addr + surface->size)) { | ||
| 970 | ASSERT_MSG(cpu_addr == surface_cpu_addr, "overlapping surfaces are unsupported"); | ||
| 971 | gpu_addresses.push_back(surface->addr); | ||
| 972 | } | ||
| 973 | } | ||
| 974 | } | ||
| 975 | |||
| 976 | if (gpu_addresses.empty()) { | ||
| 977 | return {}; | ||
| 978 | } | ||
| 979 | |||
| 980 | ASSERT_MSG(gpu_addresses.size() == 1, ">1 surface is unsupported"); | ||
| 981 | return gpu_addresses[0]; | ||
| 982 | } | ||
| 983 | |||
| 957 | SurfaceRect_Tuple RasterizerCacheOpenGL::GetSurfaceSubRect(const SurfaceParams& params, | 984 | SurfaceRect_Tuple RasterizerCacheOpenGL::GetSurfaceSubRect(const SurfaceParams& params, |
| 958 | ScaleMatch match_res_scale, | 985 | ScaleMatch match_res_scale, |
| 959 | bool load_if_create) { | 986 | bool load_if_create) { |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 08858bab4..dfddcce90 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -411,6 +411,9 @@ public: | |||
| 411 | Surface GetSurface(const SurfaceParams& params, ScaleMatch match_res_scale, | 411 | Surface GetSurface(const SurfaceParams& params, ScaleMatch match_res_scale, |
| 412 | bool load_if_create); | 412 | bool load_if_create); |
| 413 | 413 | ||
| 414 | /// Tries to find a framebuffer GPU address based on the provided CPU address | ||
| 415 | boost::optional<Tegra::GPUVAddr> TryFindFramebufferGpuAddress(VAddr cpu_addr) const; | ||
| 416 | |||
| 414 | /// Attempt to find a subrect (resolution scaled) of a surface, otherwise loads a texture from | 417 | /// Attempt to find a subrect (resolution scaled) of a surface, otherwise loads a texture from |
| 415 | /// Switch memory to OpenGL and caches it (if not already cached) | 418 | /// Switch memory to OpenGL and caches it (if not already cached) |
| 416 | SurfaceRect_Tuple GetSurfaceSubRect(const SurfaceParams& params, ScaleMatch match_res_scale, | 419 | SurfaceRect_Tuple GetSurfaceSubRect(const SurfaceParams& params, ScaleMatch match_res_scale, |