2015-05-24 06:32:32 +02:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
2021-07-05 03:22:19 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2015-05-24 06:32:32 +02:00
|
|
|
|
2014-02-10 13:54:46 -05:00
|
|
|
#pragma once
|
2013-02-19 18:22:38 -06:00
|
|
|
|
2017-09-09 18:30:15 +10:00
|
|
|
#include <array>
|
2013-02-19 18:22:38 -06:00
|
|
|
#include <map>
|
2015-12-20 21:49:49 -05:00
|
|
|
#include <memory>
|
2013-02-19 18:22:38 -06:00
|
|
|
|
2015-09-26 16:13:54 -04:00
|
|
|
#include "Common/CommonTypes.h"
|
2015-09-19 04:40:00 +12:00
|
|
|
#include "Common/GL/GLUtil.h"
|
2023-02-10 00:28:06 -06:00
|
|
|
#include "VideoCommon/Constants.h"
|
2023-01-27 13:21:09 +13:00
|
|
|
#include "VideoCommon/RenderState.h"
|
2013-02-19 18:22:38 -06:00
|
|
|
|
|
|
|
|
namespace OGL
|
|
|
|
|
{
|
2017-08-04 23:57:12 +02:00
|
|
|
class SamplerCache
|
2013-02-19 18:22:38 -06:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
SamplerCache();
|
|
|
|
|
~SamplerCache();
|
2013-10-29 01:23:17 -04:00
|
|
|
|
2017-08-04 23:57:12 +02:00
|
|
|
SamplerCache(const SamplerCache&) = delete;
|
|
|
|
|
SamplerCache& operator=(const SamplerCache&) = delete;
|
|
|
|
|
SamplerCache(SamplerCache&&) = delete;
|
|
|
|
|
SamplerCache& operator=(SamplerCache&&) = delete;
|
|
|
|
|
|
2017-09-09 18:30:15 +10:00
|
|
|
void SetSamplerState(u32 stage, const SamplerState& state);
|
|
|
|
|
void InvalidateBinding(u32 stage);
|
|
|
|
|
|
2013-02-19 18:22:38 -06:00
|
|
|
void Clear();
|
2015-05-29 00:53:07 +02:00
|
|
|
void BindNearestSampler(int stage);
|
|
|
|
|
void BindLinearSampler(int stage);
|
2013-10-29 01:23:17 -04:00
|
|
|
|
2013-02-19 18:22:38 -06:00
|
|
|
private:
|
2017-09-09 18:30:15 +10:00
|
|
|
static void SetParameters(GLuint sampler_id, const SamplerState& params);
|
2013-10-29 01:23:17 -04:00
|
|
|
|
2017-09-09 18:30:15 +10:00
|
|
|
std::map<SamplerState, GLuint> m_cache;
|
2023-02-10 00:28:06 -06:00
|
|
|
std::array<std::pair<SamplerState, GLuint>, VideoCommon::MAX_PIXEL_SHADER_SAMPLERS>
|
|
|
|
|
m_active_samplers{};
|
2013-10-29 01:23:17 -04:00
|
|
|
|
2017-09-09 18:30:15 +10:00
|
|
|
GLuint m_point_sampler;
|
|
|
|
|
GLuint m_linear_sampler;
|
2013-02-19 18:22:38 -06:00
|
|
|
};
|
|
|
|
|
|
2015-12-20 21:49:49 -05:00
|
|
|
extern std::unique_ptr<SamplerCache> g_sampler_cache;
|
2019-05-05 23:48:12 +00:00
|
|
|
} // namespace OGL
|