Improve Sprite programState update logic

This commit is contained in:
halx99 2021-06-27 21:43:21 +08:00
parent a84067eb74
commit de8334416d
1 changed files with 5 additions and 1 deletions

View File

@ -418,7 +418,9 @@ void Sprite::setTexture(Texture2D *texture)
}
}
bool needsUpdatePS = _texture == nullptr || _texture->getSamplerFlags() != texture->getSamplerFlags();
bool needsUpdatePS =
(!_programState || _programState->getProgram()->getProgramType() < backend::ProgramType::CUSTOM_PROGRAM) &&
(_texture == nullptr || _texture->getSamplerFlags() != texture->getSamplerFlags());
if (_renderMode != RenderMode::QUAD_BATCHNODE)
{
@ -433,6 +435,8 @@ void Sprite::setTexture(Texture2D *texture)
if (needsUpdatePS)
setProgramState(backend::ProgramType::POSITION_TEXTURE_COLOR);
else
updateProgramStateTexture(_texture);
}
Texture2D* Sprite::getTexture() const