2015-05-23 22:32:32 -06:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2013-02-19 17:22:38 -07:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "VideoBackends/OGL/GLUtil.h"
|
2014-02-19 04:14:09 -07:00
|
|
|
#include "VideoBackends/OGL/Render.h"
|
2013-02-19 17:22:38 -07:00
|
|
|
|
|
|
|
namespace OGL
|
|
|
|
{
|
|
|
|
|
|
|
|
class SamplerCache : NonCopyable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SamplerCache();
|
|
|
|
~SamplerCache();
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2015-03-01 05:04:48 -07:00
|
|
|
void SetSamplerState(int stage, const TexMode0& tm0, const TexMode1& tm1, bool custom_tex);
|
2013-02-19 17:22:38 -07:00
|
|
|
void Clear();
|
2015-05-28 16:53:07 -06:00
|
|
|
void BindNearestSampler(int stage);
|
|
|
|
void BindLinearSampler(int stage);
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2013-02-19 17:22:38 -07:00
|
|
|
private:
|
|
|
|
struct Params
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
TexMode0 tm0;
|
|
|
|
TexMode1 tm1;
|
|
|
|
};
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2013-02-19 17:22:38 -07:00
|
|
|
u64 hex;
|
|
|
|
};
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2013-02-19 17:22:38 -07:00
|
|
|
Params()
|
|
|
|
: hex()
|
|
|
|
{}
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2013-02-19 17:22:38 -07: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-28 23:23:17 -06:00
|
|
|
|
2013-02-19 17:22:38 -07:00
|
|
|
bool operator<(const Params& other) const
|
|
|
|
{
|
|
|
|
return hex < other.hex;
|
|
|
|
}
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2013-02-19 17:22:38 -07:00
|
|
|
bool operator!=(const Params& other) const
|
|
|
|
{
|
|
|
|
return hex != other.hex;
|
|
|
|
}
|
|
|
|
};
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2013-02-19 17:22:38 -07:00
|
|
|
struct Value
|
|
|
|
{
|
|
|
|
Value()
|
|
|
|
: sampler_id()
|
|
|
|
{}
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2013-02-19 17:22:38 -07:00
|
|
|
GLuint sampler_id;
|
|
|
|
};
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2013-02-19 17:22:38 -07:00
|
|
|
void SetParameters(GLuint sampler_id, const Params& params);
|
2013-02-20 15:58:17 -07:00
|
|
|
Value& GetEntry(const Params& params);
|
2013-02-19 17:22:38 -07:00
|
|
|
|
|
|
|
std::map<Params, Value> m_cache;
|
|
|
|
std::pair<Params, Value> m_active_samplers[8];
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2013-02-19 17:22:38 -07:00
|
|
|
int m_last_max_anisotropy;
|
2015-05-28 16:53:07 -06:00
|
|
|
u32 m_sampler_id[2];
|
2013-02-19 17:22:38 -07:00
|
|
|
};
|
|
|
|
|
2013-02-26 10:30:13 -07:00
|
|
|
extern SamplerCache *g_sampler_cache;
|
|
|
|
|
2013-02-19 17:22:38 -07:00
|
|
|
}
|