| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <array> |
| 7 |
#include <map> |
| 8 |
#include <memory> |
| 9 |
|
| 10 |
#include "Common/CommonTypes.h" |
| 11 |
#include "Common/GL/GLExtensions/GLExtensions.h" |
| 12 |
#include "VideoCommon/Constants.h" |
| 13 |
#include "VideoCommon/RenderState.h" |
| 14 |
|
| 15 |
namespace OGL |
| 16 |
{ |
| 17 |
class SamplerCache |
| 18 |
{ |
| 19 |
public: |
| 20 |
SamplerCache(); |
| 21 |
~SamplerCache(); |
| 22 |
|
| 23 |
SamplerCache(const SamplerCache&) = delete; |
| 24 |
SamplerCache& operator=(const SamplerCache&) = delete; |
| 25 |
SamplerCache(SamplerCache&&) = delete; |
| 26 |
SamplerCache& operator=(SamplerCache&&) = delete; |
| 27 |
|
| 28 |
void SetSamplerState(u32 stage, const SamplerState& state); |
| 29 |
void InvalidateBinding(u32 stage); |
| 30 |
|
| 31 |
void Clear(); |
| 32 |
void BindNearestSampler(int stage); |
| 33 |
void BindLinearSampler(int stage); |
| 34 |
|
| 35 |
private: |
| 36 |
static void SetParameters(GLuint sampler_id, const SamplerState& params); |
| 37 |
|
| 38 |
std::map<SamplerState, GLuint> m_cache; |
| 39 |
std::array<std::pair<SamplerState, GLuint>, VideoCommon::MAX_PIXEL_SHADER_SAMPLERS> |
| 40 |
m_active_samplers{}; |
| 41 |
|
| 42 |
GLuint m_point_sampler; |
| 43 |
GLuint m_linear_sampler; |
| 44 |
}; |
| 45 |
|
| 46 |
extern std::unique_ptr<SamplerCache> g_sampler_cache; |
| 47 |
} |