mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-14 05:55:13 +01:00
[HACK] AMD workaround
This commit is contained in:
parent
ede0d15fec
commit
6985b13439
@ -14,16 +14,25 @@ OGLStreamBuffer::OGLStreamBuffer(GLenum target, GLsizeiptr size, bool prefer_coh
|
|||||||
gl_buffer.Create();
|
gl_buffer.Create();
|
||||||
glBindBuffer(gl_target, gl_buffer.handle);
|
glBindBuffer(gl_target, gl_buffer.handle);
|
||||||
|
|
||||||
|
GLsizeiptr allocate_size = size;
|
||||||
|
if (target == GL_ARRAY_BUFFER) {
|
||||||
|
// On AMD GPU there is a strange crash in indexed drawing. The crash happens when the buffer
|
||||||
|
// read position is near the end and the crash looks like an out-of-bound access. Doubling
|
||||||
|
// the allocation size for the vertex buffer seems to avoid the crash.
|
||||||
|
// TODO (wwylele): investigate what actually happens here.
|
||||||
|
allocate_size *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
if (GLAD_GL_ARB_buffer_storage) {
|
if (GLAD_GL_ARB_buffer_storage) {
|
||||||
persistent = true;
|
persistent = true;
|
||||||
coherent = prefer_coherent;
|
coherent = prefer_coherent;
|
||||||
GLbitfield flags =
|
GLbitfield flags =
|
||||||
GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | (coherent ? GL_MAP_COHERENT_BIT : 0);
|
GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | (coherent ? GL_MAP_COHERENT_BIT : 0);
|
||||||
glBufferStorage(gl_target, buffer_size, nullptr, flags);
|
glBufferStorage(gl_target, allocate_size, nullptr, flags);
|
||||||
mapped_ptr = static_cast<u8*>(glMapBufferRange(
|
mapped_ptr = static_cast<u8*>(glMapBufferRange(
|
||||||
gl_target, 0, buffer_size, flags | (coherent ? 0 : GL_MAP_FLUSH_EXPLICIT_BIT)));
|
gl_target, 0, buffer_size, flags | (coherent ? 0 : GL_MAP_FLUSH_EXPLICIT_BIT)));
|
||||||
} else {
|
} else {
|
||||||
glBufferData(gl_target, buffer_size, nullptr, GL_STREAM_DRAW);
|
glBufferData(gl_target, allocate_size, nullptr, GL_STREAM_DRAW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user