2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2013-02-20 00:22:38 +00:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoBackends/OGL/GLUtil.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:
|
|
|
|
SamplerCache();
|
|
|
|
~SamplerCache();
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2013-02-20 00:22:38 +00:00
|
|
|
void SetSamplerState(int stage, const TexMode0& tm0, const TexMode1& tm1);
|
|
|
|
void Clear();
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2013-02-20 00:22:38 +00:00
|
|
|
private:
|
|
|
|
struct Params
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
TexMode0 tm0;
|
|
|
|
TexMode1 tm1;
|
|
|
|
};
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2013-02-20 00:22:38 +00:00
|
|
|
u64 hex;
|
|
|
|
};
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2013-02-20 00:22:38 +00:00
|
|
|
Params()
|
|
|
|
: hex()
|
|
|
|
{}
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2013-02-20 00:22:38 +00:00
|
|
|
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.");
|
|
|
|
}
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2013-02-20 00:22:38 +00:00
|
|
|
bool operator<(const Params& other) const
|
|
|
|
{
|
|
|
|
return hex < other.hex;
|
|
|
|
}
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2013-02-20 00:22:38 +00:00
|
|
|
bool operator!=(const Params& other) const
|
|
|
|
{
|
|
|
|
return hex != other.hex;
|
|
|
|
}
|
|
|
|
};
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2013-02-20 00:22:38 +00:00
|
|
|
struct Value
|
|
|
|
{
|
|
|
|
Value()
|
|
|
|
: sampler_id()
|
|
|
|
{}
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2013-02-20 00:22:38 +00:00
|
|
|
GLuint sampler_id;
|
|
|
|
};
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2013-02-20 00:22:38 +00:00
|
|
|
void SetParameters(GLuint sampler_id, const Params& params);
|
2013-02-20 22:58:17 +00:00
|
|
|
Value& GetEntry(const Params& params);
|
2013-02-20 00:22:38 +00:00
|
|
|
|
|
|
|
std::map<Params, Value> m_cache;
|
|
|
|
std::pair<Params, Value> m_active_samplers[8];
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2013-02-20 00:22:38 +00:00
|
|
|
int m_last_max_anisotropy;
|
|
|
|
};
|
|
|
|
|
2013-02-26 17:30:13 +00:00
|
|
|
extern SamplerCache *g_sampler_cache;
|
|
|
|
|
2013-02-20 00:22:38 +00:00
|
|
|
}
|