gl: Workaround slow PBO usage with Mesa

-Mesa is currently fastest with GL_STREAM_COPY
-See https://gitlab.freedesktop.org/mesa/mesa/commit/a338dc01866ce50bf7555ee8dc08491c7f63b585
-Also see https://bugs.freedesktop.org/show_bug.cgi?id=111043
This commit is contained in:
Malcolm Jestadt
2019-07-02 22:27:54 -04:00
committed by kd-11
parent 690cdff0d3
commit b5d5113803
+6 -1
View File
@@ -723,11 +723,16 @@ namespace gl
GLsizeiptr src_mem = src->width() * src->height();
GLsizeiptr dst_mem = dst->width() * dst->height();
GLenum buffer_copy_flag = GL_STATIC_COPY;
if (gl::get_driver_caps().vendor_MESA) buffer_copy_flag = GL_STREAM_COPY;
// NOTE: Mesa lacks acceleration for PBO unpacking and is currently fastest with GL_STREAM_COPY
// See https://bugs.freedesktop.org/show_bug.cgi?id=111043
auto max_mem = std::max(src_mem, dst_mem) * 16;
if (!g_typeless_transfer_buffer || max_mem > g_typeless_transfer_buffer.size())
{
if (g_typeless_transfer_buffer) g_typeless_transfer_buffer.remove();
g_typeless_transfer_buffer.create(buffer::target::pixel_pack, max_mem, nullptr, GL_STATIC_COPY);
g_typeless_transfer_buffer.create(buffer::target::pixel_pack, max_mem, nullptr, buffer_copy_flag);
}
auto format_type = get_format_type(src->get_internal_format());