diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-04-17 01:01:07 +0200 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-06-21 02:36:11 +0200 |
commit | 4b396f375c0d32b60595f224d06b1b63d6df6b0a (patch) | |
tree | d61b116481b20802deee2472735e83c053901454 /src/video_core/renderer_opengl/gl_texture_cache.cpp | |
parent | gl_texture_cache: Add copy from multiple overlaps into a single surface (diff) | |
download | yuzu-4b396f375c0d32b60595f224d06b1b63d6df6b0a.tar yuzu-4b396f375c0d32b60595f224d06b1b63d6df6b0a.tar.gz yuzu-4b396f375c0d32b60595f224d06b1b63d6df6b0a.tar.bz2 yuzu-4b396f375c0d32b60595f224d06b1b63d6df6b0a.tar.lz yuzu-4b396f375c0d32b60595f224d06b1b63d6df6b0a.tar.xz yuzu-4b396f375c0d32b60595f224d06b1b63d6df6b0a.tar.zst yuzu-4b396f375c0d32b60595f224d06b1b63d6df6b0a.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.cpp | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index 6a6fe7cc4..da2d1e63a 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp @@ -8,6 +8,7 @@ #include "video_core/morton.h" #include "video_core/renderer_opengl/gl_resource_manager.h" #include "video_core/renderer_opengl/gl_texture_cache.h" +#include "video_core/renderer_opengl/utils.h" #include "video_core/texture_cache.h" #include "video_core/textures/convert.h" #include "video_core/textures/texture.h" @@ -285,6 +286,8 @@ void CachedSurface::LoadBuffer() { } void CachedSurface::FlushBufferImpl() { + LOG_CRITICAL(Render_OpenGL, "Flushing"); + if (!IsModified()) { return; } @@ -352,9 +355,6 @@ void CachedSurface::UploadTextureMipmap(u32 level) { if (is_compressed) { const auto image_size{static_cast<GLsizei>(params.GetHostMipmapSize(level))}; - GLint expected_size; - glGetTextureLevelParameteriv(texture.handle, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, - &expected_size); switch (params.GetTarget()) { case SurfaceTarget::Texture2D: glCompressedTextureSubImage2D(texture.handle, level, 0, 0, @@ -419,6 +419,10 @@ void CachedSurface::UploadTextureMipmap(u32 level) { } } +void CachedSurface::DecorateSurfaceName() { + LabelGLObject(GL_TEXTURE, texture.handle, GetGpuAddr()); +} + std::unique_ptr<CachedSurfaceView> CachedSurface::CreateView(const ViewKey& view_key) { return std::make_unique<CachedSurfaceView>(*this, view_key); } @@ -517,11 +521,13 @@ TextureCacheOpenGL::TextureCacheOpenGL(Core::System& system, TextureCacheOpenGL::~TextureCacheOpenGL() = default; -CachedSurfaceView* TextureCacheOpenGL::TryFastGetSurfaceView( - VAddr cpu_addr, u8* host_ptr, const SurfaceParams& new_params, bool preserve_contents, - const std::vector<CachedSurface*>& overlaps) { +CachedSurfaceView* TextureCacheOpenGL::TryFastGetSurfaceView(GPUVAddr gpu_addr, VAddr cpu_addr, + u8* host_ptr, + const SurfaceParams& new_params, + bool preserve_contents, + const std::vector<Surface>& overlaps) { if (overlaps.size() > 1) { - return TryCopyAsViews(cpu_addr, host_ptr, new_params, overlaps); + return TryCopyAsViews(gpu_addr, cpu_addr, host_ptr, new_params, overlaps); } const auto& old_surface{overlaps[0]}; @@ -530,18 +536,18 @@ CachedSurfaceView* TextureCacheOpenGL::TryFastGetSurfaceView( old_params.GetDepth() == new_params.GetDepth() && old_params.GetDepth() == 1 && old_params.GetNumLevels() == new_params.GetNumLevels() && old_params.GetPixelFormat() == new_params.GetPixelFormat()) { - return SurfaceCopy(cpu_addr, host_ptr, new_params, old_surface, old_params); + return SurfaceCopy(gpu_addr, cpu_addr, host_ptr, new_params, old_surface, old_params); } return nullptr; } -CachedSurfaceView* TextureCacheOpenGL::SurfaceCopy(VAddr cpu_addr, u8* host_ptr, +CachedSurfaceView* TextureCacheOpenGL::SurfaceCopy(GPUVAddr gpu_addr, VAddr cpu_addr, u8* host_ptr, const SurfaceParams& new_params, - CachedSurface* old_surface, + const Surface& old_surface, const SurfaceParams& old_params) { - CachedSurface* const new_surface{GetUncachedSurface(new_params)}; - Register(new_surface, cpu_addr, host_ptr); + const auto new_surface{GetUncachedSurface(new_params)}; + Register(new_surface, gpu_addr, cpu_addr, host_ptr); const u32 min_width{ std::max(old_params.GetDefaultBlockWidth(), new_params.GetDefaultBlockWidth())}; @@ -562,12 +568,12 @@ CachedSurfaceView* TextureCacheOpenGL::SurfaceCopy(VAddr cpu_addr, u8* host_ptr, new_surface->MarkAsModified(true); // TODO(Rodrigo): Add an entry to directly get the superview - return new_surface->GetView(cpu_addr, new_params); + return new_surface->GetView(gpu_addr, new_params); } -CachedSurfaceView* TextureCacheOpenGL::TryCopyAsViews(VAddr cpu_addr, u8* host_ptr, - const SurfaceParams& new_params, - const std::vector<CachedSurface*>& overlaps) { +CachedSurfaceView* TextureCacheOpenGL::TryCopyAsViews(GPUVAddr gpu_addr, VAddr cpu_addr, + u8* host_ptr, const SurfaceParams& new_params, + const std::vector<Surface>& overlaps) { if (new_params.GetTarget() == SurfaceTarget::Texture1D || new_params.GetTarget() == SurfaceTarget::Texture1DArray || new_params.GetTarget() == SurfaceTarget::Texture3D) { @@ -575,16 +581,16 @@ CachedSurfaceView* TextureCacheOpenGL::TryCopyAsViews(VAddr cpu_addr, u8* host_p return nullptr; } - CachedSurface* const new_surface{GetUncachedSurface(new_params)}; + const auto new_surface{GetUncachedSurface(new_params)}; // TODO(Rodrigo): Move this down - Register(new_surface, cpu_addr, host_ptr); + Register(new_surface, gpu_addr, cpu_addr, host_ptr); // TODO(Rodrigo): Find a way to avoid heap allocations here. std::vector<CachedSurfaceView*> views; views.reserve(overlaps.size()); for (const auto& overlap : overlaps) { const auto view{ - new_surface->TryGetView(overlap->GetCpuAddr(), overlap->GetSurfaceParams())}; + new_surface->TryGetView(overlap->GetGpuAddr(), overlap->GetSurfaceParams())}; if (!view) { // TODO(Rodrigo): Remove this Unregister(new_surface); @@ -610,11 +616,11 @@ CachedSurfaceView* TextureCacheOpenGL::TryCopyAsViews(VAddr cpu_addr, u8* host_p new_surface->MarkAsModified(true); // TODO(Rodrigo): Add an entry to directly get the superview - return new_surface->GetView(cpu_addr, new_params); + return new_surface->GetView(gpu_addr, new_params); } -std::unique_ptr<CachedSurface> TextureCacheOpenGL::CreateSurface(const SurfaceParams& params) { - return std::make_unique<CachedSurface>(params); +Surface TextureCacheOpenGL::CreateSurface(const SurfaceParams& params) { + return std::make_unique<CachedSurface>(*this, params); } } // namespace OpenGL |