Skip to content

Commit

Permalink
Merge pull request #3298 from Sonicadvance1/max_texture_buffer_size
Browse files Browse the repository at this point in the history
Make sure not to use a GL texture buffer past the max size.
  • Loading branch information
degasus committed Nov 30, 2015
2 parents 73c904f + 21b7081 commit 5eabbd0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Source/Core/VideoBackends/OGL/TextureCache.cpp
Expand Up @@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include <algorithm>
#include <cmath>
#include <fstream>
#include <vector>
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5eabbd0

Please sign in to comment.