summaryrefslogtreecommitdiff
path: root/Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2013-02-20 16:58:17 -0600
committerJordan Woyak <jordan.woyak@gmail.com>2013-02-20 17:15:10 -0600
commite7c93b8ac30504d577d06c2dcf342043cc27ddab (patch)
treec97a0745d031ea499149b4a20e2f3182f3cd8c3e /Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.cpp
parenteae20b77a8b5205611fc778d97e4b903318d1ceb (diff)
Minor sampler cache cleanup.
Diffstat (limited to 'Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.cpp')
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.cpp22
1 files changed, 8 insertions, 14 deletions
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.cpp
index b0e6e1f8aa..d883d7e981 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.cpp
@@ -49,36 +49,30 @@ void SamplerCache::SetSamplerState(int stage, const TexMode0& tm0, const TexMode
// TODO: Should keep a circular buffer for each stage of recently used samplers.
- auto const& active_sampler = m_active_samplers[stage];
+ auto& active_sampler = m_active_samplers[stage];
if (active_sampler.first != params || !active_sampler.second.sampler_id)
{
// Active sampler does not match parameters (or is invalid), bind the proper one.
- auto const new_sampler = GetEntry(params);
-
- glBindSampler(stage, new_sampler.second.sampler_id);
- m_active_samplers[stage] = new_sampler;
+ active_sampler.first = params;
+ active_sampler.second = GetEntry(params);
+ glBindSampler(stage, active_sampler.second.sampler_id);
}
-
- //active_it->second.last_frame_used = frameCount;
}
-auto SamplerCache::GetEntry(const Params& params) -> std::pair<Params, Value>
+auto SamplerCache::GetEntry(const Params& params) -> Value&
{
- auto it = m_cache.find(params);
- if (m_cache.end() == it)
+ auto& val = m_cache[params];
+ if (!val.sampler_id)
{
// Sampler not found in cache, create it.
- Value val;
glGenSamplers(1, &val.sampler_id);
SetParameters(val.sampler_id, params);
- it = m_cache.insert(std::make_pair(params, val)).first;
-
// TODO: Maybe kill old samplers if the cache gets huge. It doesn't seem to get huge though.
//ERROR_LOG(VIDEO, "Sampler cache size is now %ld.", m_cache.size());
}
- return *it;
+ return val;
}
void SamplerCache::SetParameters(GLuint sampler_id, const Params& params)