2015-05-24 04:32:32 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2013-02-20 00:22:38 +00:00
|
|
|
|
|
|
|
#include <map>
|
2015-12-21 02:49:49 +00:00
|
|
|
#include <memory>
|
2013-02-20 00:22:38 +00:00
|
|
|
|
2015-09-26 20:13:54 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2015-09-18 16:40:00 +00:00
|
|
|
#include "Common/GL/GLUtil.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "Common/NonCopyable.h"
|
2014-02-19 11:14:09 +00:00
|
|
|
#include "VideoBackends/OGL/Render.h"
|
2013-02-20 00:22:38 +00:00
|
|
|
|
|
|
|
namespace OGL
|
|
|
|
{
|
|
|
|
class SamplerCache : NonCopyable
|
|
|
|
{
|
|
|
|
public:
|
2016-06-24 08:43:46 +00:00
|
|
|
SamplerCache();
|
|
|
|
~SamplerCache();
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
void SetSamplerState(int stage, const TexMode0& tm0, const TexMode1& tm1, bool custom_tex);
|
|
|
|
void Clear();
|
|
|
|
void BindNearestSampler(int stage);
|
|
|
|
void BindLinearSampler(int stage);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2013-02-20 00:22:38 +00:00
|
|
|
private:
|
2016-06-24 08:43:46 +00:00
|
|
|
struct Params
|
|
|
|
{
|
|
|
|
union {
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
TexMode0 tm0;
|
|
|
|
TexMode1 tm1;
|
|
|
|
};
|
|
|
|
|
|
|
|
u64 hex;
|
|
|
|
};
|
|
|
|
|
|
|
|
Params() : hex() {}
|
|
|
|
Params(const TexMode0& _tm0, const TexMode1& _tm1) : tm0(_tm0), tm1(_tm1)
|
|
|
|
{
|
|
|
|
static_assert(sizeof(Params) == 8, "Assuming I can treat this as a 64bit int.");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator<(const Params& other) const { return hex < other.hex; }
|
|
|
|
bool operator!=(const Params& other) const { return hex != other.hex; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Value
|
|
|
|
{
|
|
|
|
Value() : sampler_id() {}
|
|
|
|
GLuint sampler_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
void SetParameters(GLuint sampler_id, const Params& params);
|
|
|
|
Value& GetEntry(const Params& params);
|
|
|
|
|
|
|
|
std::map<Params, Value> m_cache;
|
|
|
|
std::pair<Params, Value> m_active_samplers[8];
|
|
|
|
|
|
|
|
int m_last_max_anisotropy;
|
|
|
|
u32 m_sampler_id[2];
|
2013-02-20 00:22:38 +00:00
|
|
|
};
|
|
|
|
|
2015-12-21 02:49:49 +00:00
|
|
|
extern std::unique_ptr<SamplerCache> g_sampler_cache;
|
2013-02-20 00:22:38 +00:00
|
|
|
}
|