GSDevice: Add ClearSamplerCache() method

This commit is contained in:
Connor McLaughlin 2022-01-01 20:12:32 +10:00 committed by refractionpcsx2
parent 0ce21c91ef
commit 0872d024f9
8 changed files with 38 additions and 0 deletions

View File

@ -241,6 +241,10 @@ void GSDevice::PurgePool()
m_pool.clear();
}
void GSDevice::ClearSamplerCache()
{
}
GSTexture* GSDevice::CreateSparseRenderTarget(int w, int h, GSTexture::Format format, bool clear)
{
return FetchSurface(HasColorSparse() ? GSTexture::Type::SparseRenderTarget : GSTexture::Type::RenderTarget, w, h, false, format, clear, true);

View File

@ -656,6 +656,8 @@ public:
void AgePool();
void PurgePool();
virtual void ClearSamplerCache();
virtual void PrintMemoryUsage();
// Convert the GS blend equations to HW specific blend factors/ops

View File

@ -297,6 +297,8 @@ public:
void RenderHW(GSHWDrawConfig& config) final;
void ClearSamplerCache() final;
ID3D11Device* operator->() { return m_dev.get(); }
operator ID3D11Device*() { return m_dev.get(); }
operator ID3D11DeviceContext*() { return m_ctx.get(); }

View File

@ -257,6 +257,11 @@ void GSDevice11::SetupPS(PSSelector sel, const GSHWDrawConfig::PSConstantBuffer*
PSSetShader(i->second.get(), m_ps_cb.get());
}
void GSDevice11::ClearSamplerCache()
{
m_ps_ss.clear();
}
void GSDevice11::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, u8 afix)
{
auto i = std::as_const(m_om_dss).find(dssel.key);

View File

@ -1610,6 +1610,16 @@ void GSDeviceOGL::PSSetSamplerState(GLuint ss)
}
}
void GSDeviceOGL::ClearSamplerCache()
{
glDeleteSamplers(std::size(m_ps_ss), m_ps_ss);
for (u32 key = 0; key < std::size(m_ps_ss); key++)
{
m_ps_ss[key] = CreateSampler(PSSamplerSelector(key));
}
}
void GSDeviceOGL::OMAttachRt(GSTextureOGL* rt)
{
GLuint id = 0;

View File

@ -371,6 +371,7 @@ public:
void PSSetShaderResource(int i, GSTexture* sr);
void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1);
void PSSetSamplerState(GLuint ss);
void ClearSamplerCache() final;
void OMSetDepthStencilState(GSDepthStencilOGL* dss);
void OMSetBlendState(u8 blend_index = 0, u8 blend_factor = 0, bool is_blend_constant = false, bool accumulation_blend = false, bool blend_mix = false);

View File

@ -990,6 +990,19 @@ VkSampler GSDeviceVK::GetSampler(GSHWDrawConfig::SamplerSelector ss)
return sampler;
}
void GSDeviceVK::ClearSamplerCache()
{
for (const auto& it : m_samplers)
g_vulkan_context->DeferSamplerDestruction(it.second);
m_samplers.clear();
m_point_sampler = GetSampler(GSHWDrawConfig::SamplerSelector::Point());
m_linear_sampler = GetSampler(GSHWDrawConfig::SamplerSelector::Linear());
m_utility_sampler = m_point_sampler;
for (u32 i = 0; i < std::size(m_tfx_samplers); i++)
m_tfx_samplers[i] = GetSampler(m_tfx_sampler_sel[i]);
}
static void AddMacro(std::stringstream& ss, const char* name, const char* value)
{
ss << "#define " << name << " " << value << "\n";

View File

@ -167,6 +167,7 @@ private:
u16 ConvertBlendEnum(u16 generic) final;
VkSampler GetSampler(GSHWDrawConfig::SamplerSelector ss);
void ClearSamplerCache() final;
VkShaderModule GetTFXVertexShader(GSHWDrawConfig::VSSelector sel);
VkShaderModule GetTFXGeometryShader(GSHWDrawConfig::GSSelector sel);