2015-05-24 06:32:32 +02:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
2014-02-10 13:54:46 -05:00
|
|
|
#pragma once
|
2013-02-19 18:22:38 -06:00
|
|
|
|
2017-09-09 18:30:15 +10:00
|
|
|
#include <array>
|
2013-02-19 18:22:38 -06:00
|
|
|
#include <map>
|
2015-12-20 21:49:49 -05:00
|
|
|
#include <memory>
|
2013-02-19 18:22:38 -06:00
|
|
|
|
2015-09-26 16:13:54 -04:00
|
|
|
#include "Common/CommonTypes.h"
|
2015-09-19 04:40:00 +12:00
|
|
|
#include "Common/GL/GLUtil.h"
|
2014-02-19 12:14:09 +01:00
|
|
|
#include "VideoBackends/OGL/Render.h"
|
2013-02-19 18:22:38 -06:00
|
|
|
|
|
|
|
|
namespace OGL
|
|
|
|
|
{
|
2017-08-04 23:57:12 +02:00
|
|
|
class SamplerCache
|
2013-02-19 18:22:38 -06:00
|
|
|
{
|
|
|
|
|
public:
|
2016-06-24 10:43:46 +02:00
|
|
|
SamplerCache();
|
|
|
|
|
~SamplerCache();
|
2013-10-29 01:23:17 -04:00
|
|
|
|
2017-08-04 23:57:12 +02:00
|
|
|
SamplerCache(const SamplerCache&) = delete;
|
|
|
|
|
SamplerCache& operator=(const SamplerCache&) = delete;
|
|
|
|
|
SamplerCache(SamplerCache&&) = delete;
|
|
|
|
|
SamplerCache& operator=(SamplerCache&&) = delete;
|
|
|
|
|
|
2017-09-09 18:30:15 +10:00
|
|
|
void SetSamplerState(u32 stage, const SamplerState& state);
|
|
|
|
|
void InvalidateBinding(u32 stage);
|
|
|
|
|
|
2016-06-24 10:43:46 +02:00
|
|
|
void Clear();
|
|
|
|
|
void BindNearestSampler(int stage);
|
|
|
|
|
void BindLinearSampler(int stage);
|
2013-10-29 01:23:17 -04:00
|
|
|
|
2013-02-19 18:22:38 -06:00
|
|
|
private:
|
2017-09-09 18:30:15 +10:00
|
|
|
static void SetParameters(GLuint sampler_id, const SamplerState& params);
|
2013-10-29 01:23:17 -04:00
|
|
|
|
2017-09-09 18:30:15 +10:00
|
|
|
std::map<SamplerState, GLuint> m_cache;
|
|
|
|
|
std::array<std::pair<SamplerState, GLuint>, 8> m_active_samplers{};
|
2013-10-29 01:23:17 -04:00
|
|
|
|
2017-09-09 18:30:15 +10:00
|
|
|
GLuint m_point_sampler;
|
|
|
|
|
GLuint m_linear_sampler;
|
2013-02-19 18:22:38 -06:00
|
|
|
};
|
|
|
|
|
|
2015-12-20 21:49:49 -05:00
|
|
|
extern std::unique_ptr<SamplerCache> g_sampler_cache;
|
2013-02-19 18:22:38 -06:00
|
|
|
}
|