Optimized Renderer
Renderer was doing useless glActiveTexture calls Former-commit-id: 5b27c6dcf9382cae79f5fc92577b42e92b851351
This commit is contained in:
parent
4026e310bc
commit
3ddcd3b7ed
|
|
@ -64,7 +64,6 @@ namespace
|
||||||
NzTextureSampler sampler;
|
NzTextureSampler sampler;
|
||||||
const NzTexture* texture = nullptr;
|
const NzTexture* texture = nullptr;
|
||||||
bool samplerUpdated = false;
|
bool samplerUpdated = false;
|
||||||
bool textureUpdated = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
using VAO_Key = std::tuple<const NzIndexBuffer*, const NzVertexBuffer*, const NzVertexDeclaration*, const NzVertexDeclaration*>;
|
using VAO_Key = std::tuple<const NzIndexBuffer*, const NzVertexBuffer*, const NzVertexDeclaration*, const NzVertexDeclaration*>;
|
||||||
|
|
@ -1372,7 +1371,6 @@ void NzRenderer::SetTexture(nzUInt8 unit, const NzTexture* texture)
|
||||||
if (s_textureUnits[unit].texture != texture)
|
if (s_textureUnits[unit].texture != texture)
|
||||||
{
|
{
|
||||||
s_textureUnits[unit].texture = texture;
|
s_textureUnits[unit].texture = texture;
|
||||||
s_textureUnits[unit].textureUpdated = false;
|
|
||||||
|
|
||||||
if (texture)
|
if (texture)
|
||||||
{
|
{
|
||||||
|
|
@ -1583,37 +1581,22 @@ bool NzRenderer::EnsureStateUpdate()
|
||||||
{
|
{
|
||||||
TextureUnit& unit = s_textureUnits[i];
|
TextureUnit& unit = s_textureUnits[i];
|
||||||
|
|
||||||
if (unit.texture)
|
if (unit.texture && !unit.samplerUpdated)
|
||||||
{
|
|
||||||
if (!unit.textureUpdated)
|
|
||||||
{
|
|
||||||
NzOpenGL::BindTextureUnit(i);
|
|
||||||
unit.texture->EnsureMipmapsUpdate();
|
|
||||||
|
|
||||||
unit.textureUpdated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!unit.samplerUpdated)
|
|
||||||
{
|
{
|
||||||
unit.sampler.Bind(i);
|
unit.sampler.Bind(i);
|
||||||
unit.samplerUpdated = true;
|
unit.samplerUpdated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (unsigned int i : s_dirtyTextureUnits)
|
for (unsigned int i : s_dirtyTextureUnits)
|
||||||
{
|
{
|
||||||
TextureUnit& unit = s_textureUnits[i];
|
TextureUnit& unit = s_textureUnits[i];
|
||||||
|
|
||||||
if (unit.texture)
|
if (unit.texture && !unit.samplerUpdated)
|
||||||
{
|
{
|
||||||
NzOpenGL::BindTextureUnit(i);
|
NzOpenGL::BindTextureUnit(i);
|
||||||
|
|
||||||
unit.texture->EnsureMipmapsUpdate();
|
|
||||||
unit.textureUpdated = true;
|
|
||||||
|
|
||||||
unit.sampler.Apply(unit.texture);
|
unit.sampler.Apply(unit.texture);
|
||||||
unit.samplerUpdated = true;
|
unit.samplerUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
@ -1819,7 +1802,10 @@ bool NzRenderer::EnsureStateUpdate()
|
||||||
{
|
{
|
||||||
const NzTexture* texture = s_textureUnits[i].texture;
|
const NzTexture* texture = s_textureUnits[i].texture;
|
||||||
if (texture)
|
if (texture)
|
||||||
|
{
|
||||||
NzOpenGL::BindTexture(i, texture->GetType(), texture->GetOpenGLID());
|
NzOpenGL::BindTexture(i, texture->GetType(), texture->GetOpenGLID());
|
||||||
|
texture->EnsureMipmapsUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Et on termine par envoyer nos états au driver
|
// Et on termine par envoyer nos états au driver
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue