summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/OGL/TextureCache.cpp
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2015-11-30 01:16:26 -0600
committerRyan Houdek <Sonicadvance1@gmail.com>2015-11-30 01:18:03 -0600
commit21b708106c839e122a8911c06085200f399317a2 (patch)
treeffa41fdd1f57fee329e363a02c1dba1e3097e251 /Source/Core/VideoBackends/OGL/TextureCache.cpp
parent73c904f0d0cd4f2bffc5e0c2118530a31adf5032 (diff)
Make sure not to use a GL texture buffer past the max size.
The spec says that vendors can set the max texture size to be 65KB and we want 1MB. Check the maximum supported and drop to the max if it is less than 1MB
Diffstat (limited to 'Source/Core/VideoBackends/OGL/TextureCache.cpp')
-rw-r--r--Source/Core/VideoBackends/OGL/TextureCache.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/Source/Core/VideoBackends/OGL/TextureCache.cpp b/Source/Core/VideoBackends/OGL/TextureCache.cpp
index 5ffd87699b..3b07b44319 100644
--- a/Source/Core/VideoBackends/OGL/TextureCache.cpp
+++ b/Source/Core/VideoBackends/OGL/TextureCache.cpp
@@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
+#include <algorithm>
#include <cmath>
#include <fstream>
#include <vector>
@@ -293,7 +294,17 @@ TextureCache::TextureCache()
if (g_ActiveConfig.backend_info.bSupportsPaletteConversion)
{
- s_palette_stream_buffer = StreamBuffer::Create(GL_TEXTURE_BUFFER, 1024*1024);
+ s32 buffer_size = 1024 * 1024;
+ s32 max_buffer_size = 0;
+
+ // The minimum MAX_TEXTURE_BUFFER_SIZE that the spec mandates
+ // is 65KB, we are asking for a 1MB buffer here.
+ // Make sure to check the maximum size and if it is below 1MB
+ // then use the maximum the hardware supports instead.
+ glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &max_buffer_size);
+ buffer_size = std::min(buffer_size, max_buffer_size);
+
+ s_palette_stream_buffer = StreamBuffer::Create(GL_TEXTURE_BUFFER, buffer_size);
glGenTextures(1, &s_palette_resolv_texture);
glBindTexture(GL_TEXTURE_BUFFER, s_palette_resolv_texture);
glTexBuffer(GL_TEXTURE_BUFFER, GL_R16UI, s_palette_stream_buffer->m_buffer);