Graphics: Improve TextureSampler handling

This commit is contained in:
Jérôme Leclercq
2021-01-27 18:50:49 +01:00
parent 78c3f57333
commit b9151d8a7a
15 changed files with 181 additions and 27 deletions

View File

@@ -436,10 +436,10 @@ namespace Nz
return m_textures[textureIndex].texture;
}
inline const std::shared_ptr<TextureSampler>& Material::GetTextureSampler(std::size_t textureIndex) const
inline const TextureSamplerInfo& Material::GetTextureSampler(std::size_t textureIndex) const
{
NazaraAssert(textureIndex < m_textures.size(), "Invalid texture index");
return m_textures[textureIndex].sampler;
return m_textures[textureIndex].samplerInfo;
}
inline const std::shared_ptr<AbstractBuffer>& Material::GetUniformBuffer(std::size_t bufferIndex) const
@@ -695,13 +695,13 @@ namespace Nz
}
}
inline void Material::SetTextureSampler(std::size_t textureIndex, std::shared_ptr<TextureSampler> sampler)
inline void Material::SetTextureSampler(std::size_t textureIndex, TextureSamplerInfo samplerInfo)
{
NazaraAssert(textureIndex < m_textures.size(), "Invalid texture index");
if (m_textures[textureIndex].sampler != sampler)
if (m_textures[textureIndex].samplerInfo != samplerInfo)
{
m_textures[textureIndex].sampler = std::move(sampler);
InvalidateShaderBinding();
m_textures[textureIndex].samplerInfo = std::move(samplerInfo);
InvalidateTextureSampler(textureIndex);
}
}
@@ -731,6 +731,14 @@ namespace Nz
//TODO
}
inline void Material::InvalidateTextureSampler(std::size_t textureIndex)
{
assert(textureIndex < m_textures.size());
m_textures[textureIndex].sampler.reset();
InvalidateShaderBinding();
}
inline void Material::UpdatePipeline() const
{
for (auto& shader : m_pipelineInfo.shaders)