perf: Do not unbind textures

It is redundant and reduces performance.
This commit is contained in:
Vsevolod Kremianskii 2020-11-15 18:56:47 +07:00
parent aa128580ab
commit c7752b2e87
10 changed files with 0 additions and 44 deletions

View file

@ -177,8 +177,6 @@ void SelectionOverlay::drawReticle(Texture &texture, const glm::vec3 &screenCoor
texture.bind(0);
Quad::getDefault().renderTriangles();
texture.unbind(0);
}
void SelectionOverlay::drawTitleBar() const {
@ -248,8 +246,6 @@ void SelectionOverlay::drawActionBar() const {
Quad::getDefault().renderTriangles();
frameTexture->unbind(0);
if (i < static_cast<int>(_actions.size())) {
ContextualAction action = _actions[i];
@ -269,8 +265,6 @@ void SelectionOverlay::drawActionBar() const {
texture->bind(0);
Quad::getDefault().renderTriangles();
texture->unbind(0);
}
}
}

View file

@ -266,8 +266,6 @@ void Control::drawBorder(const Border &border, const glm::ivec2 &offset, const g
} else {
Quad::getDefault().renderTriangles();
}
border.fill->unbind(0);
}
if (border.edge) {
int width = size.x - 2 * border.dimension;
@ -343,8 +341,6 @@ void Control::drawBorder(const Border &border, const glm::ivec2 &offset, const g
}
Quad::getYFlipped().renderTriangles();
}
border.edge->unbind(0);
}
if (border.corner) {
int x = _extent.left + offset.x;
@ -407,8 +403,6 @@ void Control::drawBorder(const Border &border, const glm::ivec2 &offset, const g
Shaders::instance().activate(ShaderProgram::GUIGUI, locals);
}
Quad::getXYFlipped().renderTriangles();
border.corner->unbind(0);
}
}

View file

@ -77,7 +77,6 @@ void ImageButton::drawIcon(const glm::ivec2 &offset, const shared_ptr<Texture> &
if (_iconFrame) {
_iconFrame->bind(0);
Quad::getDefault().renderTriangles();
_iconFrame->unbind(0);
}
{
LocalUniforms locals;
@ -88,7 +87,6 @@ void ImageButton::drawIcon(const glm::ivec2 &offset, const shared_ptr<Texture> &
if (icon) {
icon->bind(0);
Quad::getDefault().renderTriangles();
icon->unbind(0);
}
}

View file

@ -51,8 +51,6 @@ void ScrollBar::render(const glm::ivec2 &offset, const string &textOverride) con
if (_canScrollUp) drawUpArrow(offset);
if (_canScrollDown) drawDownArrow(offset);
_dir.image->unbind(0);
}
void ScrollBar::drawUpArrow(const glm::vec2 &offset) const {

View file

@ -267,8 +267,6 @@ void GUI::drawBackground() const {
_background->bind(0);
Quad::getDefault().renderTriangles();
_background->unbind(0);
}
void GUI::resetFocus() {

View file

@ -56,8 +56,6 @@ void Cursor::render() const {
texture->bind(0);
Quad::getDefault().renderTriangles();
texture->unbind(0);
}
void Cursor::setPosition(const glm::ivec2 &position) {

View file

@ -146,8 +146,6 @@ void Font::render(const string &text, const glm::mat4 &transform, const glm::vec
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindVertexArray(0);
_texture->unbind(0);
}
float Font::measure(const string &text) const {

View file

@ -65,22 +65,6 @@ void ModelMesh::render(const shared_ptr<Texture> &diffuseOverride) const {
if (additive) {
glBlendFuncSeparate(blendSrcRgb, blendDstRgb, blendSrcAlpha, blendDstAlpha);
}
if (_bumpmap) {
_bumpmap->unbind(4);
}
if (_bumpyShiny) {
_bumpyShiny->unbind(3);
}
if (_lightmap) {
_lightmap->unbind(2);
}
if (_envmap) {
_envmap->unbind(1);
}
if (diffuse) {
diffuse->unbind(0);
}
}
bool ModelMesh::shouldRender() const {

View file

@ -159,11 +159,6 @@ void Texture::bind(int unit) {
glBindTexture(isCubeMap() ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D, _textureId);
}
void Texture::unbind(int unit) {
glActiveTexture(GL_TEXTURE0 + unit);
glBindTexture(isCubeMap() ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D, 0);
}
bool Texture::isAdditive() const {
return _features.blending == TextureBlending::Additive;
}

View file

@ -49,7 +49,6 @@ public:
void initGL();
void deinitGL();
void bind(int unit);
void unbind(int unit);
bool isAdditive() const;