From 92fb828d52d538b910eccbde3d5df2b8a09799db Mon Sep 17 00:00:00 2001 From: kd-11 Date: Mon, 19 Mar 2018 23:43:55 +0300 Subject: [PATCH] gl: Compat support for mesa drivers Needs CLIENT_STORAGE bit set for persistent buffers to make them useful --- rpcs3/Emu/RSX/GL/GLHelpers.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/RSX/GL/GLHelpers.h b/rpcs3/Emu/RSX/GL/GLHelpers.h index c4d911888a..2c66ef4a54 100644 --- a/rpcs3/Emu/RSX/GL/GLHelpers.h +++ b/rpcs3/Emu/RSX/GL/GLHelpers.h @@ -88,6 +88,7 @@ namespace gl bool vendor_INTEL = false; //has broken GLSL compiler bool vendor_AMD = false; //has broken ARB_multidraw bool vendor_NVIDIA = false; //has NaN poisoning issues + bool vendor_MESA = false; //requires CLIENT_STORAGE bit set for streaming buffers void initialize() { @@ -200,6 +201,10 @@ namespace gl { vendor_NVIDIA = true; } + else if (vendor_string.find("x.org") != std::string::npos) + { + vendor_MESA = true; + } #ifdef _WIN32 else if (vendor_string.find("amd") != std::string::npos || vendor_string.find("ati") != std::string::npos) { @@ -868,8 +873,11 @@ namespace gl buffer::create(); + GLbitfield buffer_storage_flags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT; + if (get_driver_caps().vendor_MESA) buffer_storage_flags |= GL_CLIENT_STORAGE_BIT; + glBindBuffer((GLenum)m_target, m_id); - glBufferStorage((GLenum)m_target, size, data, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + glBufferStorage((GLenum)m_target, size, data, buffer_storage_flags); m_memory_mapping = glMapBufferRange((GLenum)m_target, 0, size, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); verify(HERE), m_memory_mapping != nullptr;