gl: Compat support for mesa drivers Needs CLIENT_STORAGE bit set for persistent buffers to make them useful

This commit is contained in:
kd-11 2018-03-19 23:43:55 +03:00
parent d13584f858
commit 92fb828d52

View File

@ -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;