Skip to content

Commit

Permalink
Merge pull request #790 from edge-classic/gl-unit-regression-fix
Browse files Browse the repository at this point in the history
Fix performance regression in legacy GL r_units code
  • Loading branch information
dashodanger authored Jan 4, 2025
2 parents 7d7b56b + 4f0e661 commit 4addbdc
Show file tree
Hide file tree
Showing 3 changed files with 240 additions and 122 deletions.
5 changes: 5 additions & 0 deletions source_files/edge/r_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ class RenderState
virtual void Flush() = 0;

virtual void SetPipeline(uint32_t flags) = 0;

// Needed only for the legacy GL render path when ending unit batches
#ifndef EDGE_SOKOL
virtual void ResetGLState() = 0;
#endif
};

extern RenderState *render_state;
Expand Down
27 changes: 27 additions & 0 deletions source_files/edge/render/gl/gl_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,33 @@ class GLRenderState : public RenderState
EPI_UNUSED(flags);
}

// Might need to add more here since the state's scope has expanded - Dasho
void ResetGLState()
{
Disable(GL_BLEND);
BlendFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

Disable(GL_ALPHA_TEST);

DepthMask(true);

CullFace(GL_BACK);
Disable(GL_CULL_FACE);

Disable(GL_FOG);

PolygonOffset(0, 0);

for (int i = 0; i < 2; i++)
{
bind_texture_2d_[i] = 0;
texture_environment_mode_[i] = 0;
texture_environment_combine_rgb_[i] = 0;
texture_environment_source_0_rgb_[i] = 0;
texture_wrap_t_[i] = 0;
}
}

int frameStateChanges_ = 0;

private:
Expand Down
Loading

0 comments on commit 4addbdc

Please sign in to comment.