diff options
| author | Markus Wick <degasus@users.noreply.github.com> | 2016-05-19 13:31:30 +0200 |
|---|---|---|
| committer | Markus Wick <degasus@users.noreply.github.com> | 2016-05-19 13:31:30 +0200 |
| commit | d2db329a42e8a61665f39e9d212d5ca5c35efc8a (patch) | |
| tree | 6350eebcb6aa13339b2741b416c7779d6394ced2 /Source/Core/VideoBackends/OGL/BoundingBox.cpp | |
| parent | 24ea2dc2da94cd3d6c6ea7df8d2dcb65df2bb297 (diff) | |
| parent | 89e54fbd6ca9cdfdb5766ea9ecf5fa1d81e786c7 (diff) | |
Merge pull request #3831 from stenzek/gl-bbox
OGL: Improve performance of bounding box on NVIDIA drivers
Diffstat (limited to 'Source/Core/VideoBackends/OGL/BoundingBox.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/OGL/BoundingBox.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/Source/Core/VideoBackends/OGL/BoundingBox.cpp b/Source/Core/VideoBackends/OGL/BoundingBox.cpp index b8e424f639..c4c0012ddc 100644 --- a/Source/Core/VideoBackends/OGL/BoundingBox.cpp +++ b/Source/Core/VideoBackends/OGL/BoundingBox.cpp @@ -6,6 +6,7 @@ #include "VideoBackends/OGL/BoundingBox.h" +#include "VideoCommon/DriverDetails.h" #include "VideoCommon/VideoConfig.h" static GLuint s_bbox_buffer_id; @@ -42,12 +43,25 @@ int BoundingBox::Get(int index) { int data = 0; glBindBuffer(GL_SHADER_STORAGE_BUFFER, s_bbox_buffer_id); - void* ptr = glMapBufferRange(GL_SHADER_STORAGE_BUFFER, index * sizeof(int), sizeof(int), GL_MAP_READ_BIT); - if (ptr) + + if (!DriverDetails::HasBug(DriverDetails::BUG_SLOWGETBUFFERSUBDATA)) + { + // Using glMapBufferRange to read back the contents of the SSBO is extremely slow + // on nVidia drivers. This is more noticeable at higher internal resolutions. + // Using glGetBufferSubData instead does not seem to exhibit this slowdown. + glGetBufferSubData(GL_SHADER_STORAGE_BUFFER, index * sizeof(int), sizeof(int), &data); + } + else { - data = *(int*)ptr; - glUnmapBuffer(GL_SHADER_STORAGE_BUFFER); + // Using glMapBufferRange is faster on AMD cards by a measurable margin. + void* ptr = glMapBufferRange(GL_SHADER_STORAGE_BUFFER, index * sizeof(int), sizeof(int), GL_MAP_READ_BIT); + if (ptr) + { + memcpy(&data, ptr, sizeof(int)); + glUnmapBuffer(GL_SHADER_STORAGE_BUFFER); + } } + glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0); return data; } |
