mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
LibGL: Only pass bound texture units to rasterizer
Before, `SoftwareRasterizer` was iterating over all 32 possible texture units for each fragment and checking each if they're bound to a texture. After this change, an intrusive list containing only texture units with bound textures is passed to the rasterizer. In GLQuake, this results in a performance improvement of ~30% (from 12 to 16 FPS in the first demo) on my machine.
This commit is contained in:
parent
f201567153
commit
4e3ed16527
5 changed files with 16 additions and 10 deletions
|
@ -494,17 +494,12 @@ SoftwareRasterizer::SoftwareRasterizer(const Gfx::IntSize& min_size)
|
|||
m_options.scissor_box = m_render_target->rect();
|
||||
}
|
||||
|
||||
void SoftwareRasterizer::submit_triangle(const GLTriangle& triangle, const Array<TextureUnit, 32>& texture_units)
|
||||
void SoftwareRasterizer::submit_triangle(GLTriangle const& triangle, TextureUnit::BoundList const& bound_texture_units)
|
||||
{
|
||||
rasterize_triangle(m_options, *m_render_target, *m_depth_buffer, triangle, [this, &texture_units](const FloatVector2& uv, const FloatVector4& color, float z) -> FloatVector4 {
|
||||
rasterize_triangle(m_options, *m_render_target, *m_depth_buffer, triangle, [this, &bound_texture_units](const FloatVector2& uv, const FloatVector4& color, float z) -> FloatVector4 {
|
||||
FloatVector4 fragment = color;
|
||||
|
||||
for (const auto& texture_unit : texture_units) {
|
||||
|
||||
// No texture is bound to this texture unit
|
||||
if (!texture_unit.is_bound())
|
||||
continue;
|
||||
|
||||
for (auto const& texture_unit : bound_texture_units) {
|
||||
// FIXME: implement GL_TEXTURE_1D, GL_TEXTURE_3D and GL_TEXTURE_CUBE_MAP
|
||||
FloatVector4 texel;
|
||||
switch (texture_unit.currently_bound_target()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue