Optimized Renderer
Renderer was doing useless glActiveTexture calls Former-commit-id: 5b27c6dcf9382cae79f5fc92577b42e92b851351
This commit is contained in:
@@ -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,21 +1581,10 @@ bool NzRenderer::EnsureStateUpdate()
|
|||||||
{
|
{
|
||||||
TextureUnit& unit = s_textureUnits[i];
|
TextureUnit& unit = s_textureUnits[i];
|
||||||
|
|
||||||
if (unit.texture)
|
if (unit.texture && !unit.samplerUpdated)
|
||||||
{
|
{
|
||||||
if (!unit.textureUpdated)
|
unit.sampler.Bind(i);
|
||||||
{
|
unit.samplerUpdated = true;
|
||||||
NzOpenGL::BindTextureUnit(i);
|
|
||||||
unit.texture->EnsureMipmapsUpdate();
|
|
||||||
|
|
||||||
unit.textureUpdated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!unit.samplerUpdated)
|
|
||||||
{
|
|
||||||
unit.sampler.Bind(i);
|
|
||||||
unit.samplerUpdated = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1607,13 +1594,9 @@ bool NzRenderer::EnsureStateUpdate()
|
|||||||
{
|
{
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user