Skip to content

Commit

Permalink
GS/OGL: Add fallback when copy image is not supported.
Browse files Browse the repository at this point in the history
  • Loading branch information
lightningterror committed Jul 8, 2024
1 parent 08215c3 commit 05e714b
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ namespace Emulate_DSA
glTexSubImage2D(GL_TEXTURE_2D, level, xoffset, yoffset, width, height, format, type, pixels);
}

static void GLAPIENTRY CopyTextureSubImage(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
{
BindTextureUnit(7, texture);
glCopyTexSubImage2D(GL_TEXTURE_2D, level, xoffset, yoffset, x, y, width, height);
}

static void GLAPIENTRY CompressedTextureSubImage(GLuint texture, GLint level, GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
{
Expand Down Expand Up @@ -115,6 +121,7 @@ namespace Emulate_DSA
glCreateTextures = CreateTexture;
glTextureStorage2D = TextureStorage;
glTextureSubImage2D = TextureSubImage;
glCopyTextureSubImage2D = CopyTextureSubImage;
glCompressedTextureSubImage2D = CompressedTextureSubImage;
glGetTextureImage = GetTexureImage;
glTextureParameteri = TextureParameteri;
Expand Down Expand Up @@ -669,9 +676,8 @@ bool GSDeviceOGL::CheckFeatures(bool& buggy_pbo)

if (!GLAD_GL_VERSION_4_3 && !GLAD_GL_ARB_copy_image && !GLAD_GL_EXT_copy_image)
{
Host::ReportFormattedErrorAsync(
"GS", "GL_ARB_copy_image is not supported, this is required for the OpenGL renderer.");
return false;
Host::AddOSDMessage(
"GL_ARB_copy_image is not supported, this will reduce performance.", Host::OSD_ERROR_DURATION);
}

if (!GLAD_GL_ARB_viewport_array)
Expand Down Expand Up @@ -1463,6 +1469,14 @@ void GSDeviceOGL::CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r
glCopyImageSubDataEXT(sid, GL_TEXTURE_2D, 0, r.x, r.y, 0, did, GL_TEXTURE_2D,
0, destX, destY, 0, r.width(), r.height(), 1);
}
else
{
// Slower copy (conversion is done)
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read);
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, sid, 0);
glCopyTextureSubImage2D(did, 0, r.x, r.y, r.x, r.y, r.width(), r.height());
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
}
}

void GSDeviceOGL::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, ShaderConvert shader, bool linear)
Expand Down

0 comments on commit 05e714b

Please sign in to comment.