summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-04-17 01:01:07 +0200
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-06-21 02:36:11 +0200
commit4b396f375c0d32b60595f224d06b1b63d6df6b0a (patch)
treed61b116481b20802deee2472735e83c053901454 /src/video_core/renderer_opengl
parentgl_texture_cache: Add copy from multiple overlaps into a single surface (diff)
downloadyuzu-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 'src/video_core/renderer_opengl')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp8
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.cpp50
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.h20
3 files changed, 44 insertions, 34 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 07c28357e..af63365a4 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -498,8 +498,8 @@ std::pair<bool, bool> RasterizerOpenGL::ConfigureFramebuffers(
color_surface->MarkAsModified(true);
// Workaround for and issue in nvidia drivers
// https://devtalk.nvidia.com/default/topic/776591/opengl/gl_framebuffer_srgb-functions-incorrectly/
- // state.framebuffer_srgb.enabled |=
- // color_surface->GetSurfaceParams().srgb_conversion;
+ state.framebuffer_srgb.enabled |=
+ color_surface->GetSurfaceParams().GetSrgbConversion();
}
fbkey.is_single_buffer = true;
@@ -519,8 +519,8 @@ std::pair<bool, bool> RasterizerOpenGL::ConfigureFramebuffers(
// Enable sRGB only for supported formats
// Workaround for and issue in nvidia drivers
// https://devtalk.nvidia.com/default/topic/776591/opengl/gl_framebuffer_srgb-functions-incorrectly/
- // state.framebuffer_srgb.enabled |=
- // color_surface->GetSurfaceParams().srgb_conversion;
+ state.framebuffer_srgb.enabled |=
+ color_surface->GetSurfaceParams().GetSrgbConversion();
}
fbkey.color_attachments[index] =
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
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h
index 86ad91dab..8705db74c 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.h
+++ b/src/video_core/renderer_opengl/gl_texture_cache.h
@@ -27,6 +27,7 @@ using VideoCore::Surface::SurfaceType;
class CachedSurfaceView;
class CachedSurface;
+using Surface = std::shared_ptr<CachedSurface>;
using TextureCacheBase = VideoCommon::TextureCacheContextless<CachedSurface, CachedSurfaceView>;
class CachedSurface final : public VideoCommon::SurfaceBaseContextless<CachedSurfaceView> {
@@ -47,6 +48,8 @@ public:
}
protected:
+ void DecorateSurfaceName();
+
std::unique_ptr<CachedSurfaceView> CreateView(const ViewKey& view_key);
void FlushBufferImpl();
@@ -65,7 +68,6 @@ private:
OGLTexture texture;
std::vector<u8> staging_buffer;
- u8* host_ptr{};
};
class CachedSurfaceView final {
@@ -155,19 +157,21 @@ public:
~TextureCacheOpenGL();
protected:
- CachedSurfaceView* TryFastGetSurfaceView(VAddr cpu_addr, u8* host_ptr,
+ CachedSurfaceView* TryFastGetSurfaceView(GPUVAddr gpu_addr, VAddr cpu_addr, u8* host_ptr,
const SurfaceParams& new_params,
bool preserve_contents,
- const std::vector<CachedSurface*>& overlaps);
+ const std::vector<Surface>& overlaps);
- std::unique_ptr<CachedSurface> CreateSurface(const SurfaceParams& params);
+ Surface CreateSurface(const SurfaceParams& params);
private:
- CachedSurfaceView* SurfaceCopy(VAddr cpu_addr, u8* host_ptr, const SurfaceParams& new_params,
- CachedSurface* old_surface, const SurfaceParams& old_params);
+ CachedSurfaceView* SurfaceCopy(GPUVAddr gpu_addr, VAddr cpu_addr, u8* host_ptr,
+ const SurfaceParams& new_params, const Surface& old_surface,
+ const SurfaceParams& old_params);
- CachedSurfaceView* TryCopyAsViews(VAddr cpu_addr, u8* host_ptr, const SurfaceParams& new_params,
- const std::vector<CachedSurface*>& overlaps);
+ CachedSurfaceView* TryCopyAsViews(GPUVAddr gpu_addr, VAddr cpu_addr, u8* host_ptr,
+ const SurfaceParams& new_params,
+ const std::vector<Surface>& overlaps);
};
} // namespace OpenGL