GS/OpenGL: Fix uploading large (>16MB) textures

This commit is contained in:
Connor McLaughlin 2022-02-20 14:35:05 +10:00 committed by lightningterror
parent 9ed33d4337
commit 3b3072801c
1 changed files with 30 additions and 29 deletions

View File

@ -397,18 +397,17 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch, int
GL_PUSH("Upload Texture %d", m_texture_id);
g_perfmon.Put(GSPerfMon::TextureUploads, 1);
// The easy solution without PBO
#if 0
// Likely a bad texture
// Don't use PBOs for huge texture uploads, let the driver sort it out.
// Otherwise we'll just be syncing, or worse, crashing because the PBO routine above isn't great.
if (map_size >= PboPool::m_seg_size)
{
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch >> m_int_shift);
glTextureSubImage2D(m_texture_id, GL_TEX_LEVEL_0, r.x, r.y, r.width(), r.height(), m_int_format, m_int_type, data);
glTextureSubImage2D(m_texture_id, layer, r.x, r.y, r.width(), r.height(), m_int_format, m_int_type, data);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); // Restore default behavior
#endif
}
else
{
// The complex solution with PBO
#if 1
char* src = (char*)data;
char* map = PboPool::Map(map_size);
@ -429,7 +428,7 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch, int
PboPool::UnbindPbo();
PboPool::EndTransfer();
#endif
}
m_needs_mipmaps_generated = true;
@ -451,13 +450,15 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* _r, int layer)
if (m_type == Type::Texture || m_type == Type::RenderTarget)
{
const u32 map_size = r.height() * row_byte;
if (map_size > PboPool::m_seg_size)
return false;
GL_PUSH_("Upload Texture %d", m_texture_id); // POP is in Unmap
g_perfmon.Put(GSPerfMon::TextureUploads, 1);
m_clean = false;
u32 map_size = r.height() * row_byte;
m.bits = (u8*)PboPool::Map(map_size);
#ifdef ENABLE_OGL_DEBUG_MEM_BW