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-09-18 16:40:00 +00:00
|
|
|
#include "Common/GL/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
|
|
|
|
2015-03-01 12:04:48 +00:00
|
|
|
void SetSamplerState(int stage, const TexMode0& tm0, const TexMode1& tm1, bool custom_tex);
|
2013-02-20 00:22:38 +00:00
|
|
|
void Clear();
|
2015-05-28 22:53:07 +00:00
|
|
|
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:
|
|
|
|
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;
|
2015-05-28 22:53:07 +00:00
|
|
|
u32 m_sampler_id[2];
|
2013-02-20 00:22:38 +00:00
|
|
|
};
|
|
|
|
|
2013-02-26 17:30:13 +00:00
|
|
|
extern SamplerCache *g_sampler_cache;
|
|
|
|
|
2013-02-20 00:22:38 +00:00
|
|
|
}
|