mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
Implement OGL sampler cache. Allows binding a texture multiple times with different parameters. Also possibly gives a very small speed improvement.
This commit is contained in:
80
Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.h
Normal file
80
Source/Plugins/Plugin_VideoOGL/Src/SamplerCache.h
Normal file
@ -0,0 +1,80 @@
|
||||
|
||||
#ifndef INCLUDE_SAMPLER_CACHE_H_
|
||||
#define INCLUDE_SAMPLER_CACHE_H_
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "Render.h"
|
||||
#include "GLUtil.h"
|
||||
|
||||
namespace OGL
|
||||
{
|
||||
|
||||
class SamplerCache : NonCopyable
|
||||
{
|
||||
public:
|
||||
SamplerCache();
|
||||
~SamplerCache();
|
||||
|
||||
void SetSamplerState(int stage, const TexMode0& tm0, const TexMode1& tm1);
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
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()
|
||||
// , last_frame_used()
|
||||
{}
|
||||
|
||||
GLuint sampler_id;
|
||||
//int last_frame_used;
|
||||
};
|
||||
|
||||
void SetParameters(GLuint sampler_id, const Params& params);
|
||||
std::pair<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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user