|
|
@ -9,6 +9,7 @@
|
|
|
|
#include "core/core.h"
|
|
|
|
#include "core/core.h"
|
|
|
|
#include "video_core/morton.h"
|
|
|
|
#include "video_core/morton.h"
|
|
|
|
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
|
|
|
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
|
|
|
|
|
|
|
#include "video_core/renderer_opengl/gl_state.h"
|
|
|
|
#include "video_core/renderer_opengl/gl_texture_cache.h"
|
|
|
|
#include "video_core/renderer_opengl/gl_texture_cache.h"
|
|
|
|
#include "video_core/renderer_opengl/utils.h"
|
|
|
|
#include "video_core/renderer_opengl/utils.h"
|
|
|
|
#include "video_core/texture_cache/texture_cache.h"
|
|
|
|
#include "video_core/texture_cache/texture_cache.h"
|
|
|
@ -23,6 +24,7 @@ using VideoCore::MortonSwizzleMode;
|
|
|
|
using VideoCore::Surface::ComponentType;
|
|
|
|
using VideoCore::Surface::ComponentType;
|
|
|
|
using VideoCore::Surface::PixelFormat;
|
|
|
|
using VideoCore::Surface::PixelFormat;
|
|
|
|
using VideoCore::Surface::SurfaceTarget;
|
|
|
|
using VideoCore::Surface::SurfaceTarget;
|
|
|
|
|
|
|
|
using VideoCore::Surface::SurfaceType;
|
|
|
|
|
|
|
|
|
|
|
|
MICROPROFILE_DEFINE(OpenGL_Texture_Upload, "OpenGL", "Texture Upload", MP_RGB(128, 192, 128));
|
|
|
|
MICROPROFILE_DEFINE(OpenGL_Texture_Upload, "OpenGL", "Texture Upload", MP_RGB(128, 192, 128));
|
|
|
|
MICROPROFILE_DEFINE(OpenGL_Texture_Download, "OpenGL", "Texture Download", MP_RGB(128, 192, 128));
|
|
|
|
MICROPROFILE_DEFINE(OpenGL_Texture_Download, "OpenGL", "Texture Download", MP_RGB(128, 192, 128));
|
|
|
@ -422,7 +424,10 @@ OGLTextureView CachedSurfaceView::CreateTextureView() const {
|
|
|
|
|
|
|
|
|
|
|
|
TextureCacheOpenGL::TextureCacheOpenGL(Core::System& system,
|
|
|
|
TextureCacheOpenGL::TextureCacheOpenGL(Core::System& system,
|
|
|
|
VideoCore::RasterizerInterface& rasterizer)
|
|
|
|
VideoCore::RasterizerInterface& rasterizer)
|
|
|
|
: TextureCacheBase{system, rasterizer} {}
|
|
|
|
: TextureCacheBase{system, rasterizer} {
|
|
|
|
|
|
|
|
src_framebuffer.Create();
|
|
|
|
|
|
|
|
dst_framebuffer.Create();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TextureCacheOpenGL::~TextureCacheOpenGL() = default;
|
|
|
|
TextureCacheOpenGL::~TextureCacheOpenGL() = default;
|
|
|
|
|
|
|
|
|
|
|
@ -443,4 +448,67 @@ void TextureCacheOpenGL::ImageCopy(Surface src_surface, Surface dst_surface,
|
|
|
|
copy_params.depth);
|
|
|
|
copy_params.depth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TextureCacheOpenGL::ImageBlit(Surface src_surface, Surface dst_surface,
|
|
|
|
|
|
|
|
const Common::Rectangle<u32>& src_rect,
|
|
|
|
|
|
|
|
const Common::Rectangle<u32>& dst_rect) {
|
|
|
|
|
|
|
|
const auto& src_params{src_surface->GetSurfaceParams()};
|
|
|
|
|
|
|
|
const auto& dst_params{dst_surface->GetSurfaceParams()};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OpenGLState prev_state{OpenGLState::GetCurState()};
|
|
|
|
|
|
|
|
SCOPE_EXIT({ prev_state.Apply(); });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OpenGLState state;
|
|
|
|
|
|
|
|
state.draw.read_framebuffer = src_framebuffer.handle;
|
|
|
|
|
|
|
|
state.draw.draw_framebuffer = dst_framebuffer.handle;
|
|
|
|
|
|
|
|
state.ApplyFramebufferState();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
u32 buffers{};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UNIMPLEMENTED_IF(src_params.target != SurfaceTarget::Texture2D);
|
|
|
|
|
|
|
|
UNIMPLEMENTED_IF(dst_params.target != SurfaceTarget::Texture2D);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const GLuint src_texture{src_surface->GetTexture()};
|
|
|
|
|
|
|
|
const GLuint dst_texture{dst_surface->GetTexture()};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (src_params.type == SurfaceType::ColorTexture) {
|
|
|
|
|
|
|
|
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
|
|
|
|
|
|
|
src_texture, 0);
|
|
|
|
|
|
|
|
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0,
|
|
|
|
|
|
|
|
0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
|
|
|
|
|
|
|
dst_texture, 0);
|
|
|
|
|
|
|
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0,
|
|
|
|
|
|
|
|
0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buffers = GL_COLOR_BUFFER_BIT;
|
|
|
|
|
|
|
|
} else if (src_params.type == SurfaceType::Depth) {
|
|
|
|
|
|
|
|
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
|
|
|
|
|
|
|
|
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, src_texture,
|
|
|
|
|
|
|
|
0);
|
|
|
|
|
|
|
|
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
|
|
|
|
|
|
|
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, dst_texture,
|
|
|
|
|
|
|
|
0);
|
|
|
|
|
|
|
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buffers = GL_DEPTH_BUFFER_BIT;
|
|
|
|
|
|
|
|
} else if (src_params.type == SurfaceType::DepthStencil) {
|
|
|
|
|
|
|
|
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
|
|
|
|
|
|
|
|
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
|
|
|
|
|
|
|
|
src_texture, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
|
|
|
|
|
|
|
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
|
|
|
|
|
|
|
|
dst_texture, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buffers = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glBlitFramebuffer(src_rect.left, src_rect.top, src_rect.right, src_rect.bottom, dst_rect.left,
|
|
|
|
|
|
|
|
dst_rect.top, dst_rect.right, dst_rect.bottom, buffers,
|
|
|
|
|
|
|
|
buffers == GL_COLOR_BUFFER_BIT ? GL_LINEAR : GL_NEAREST);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace OpenGL
|
|
|
|
} // namespace OpenGL
|
|
|
|