mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
LibSoftGPU: Use multiplication instead of division for linear fog
Sampling profiling shows a reduction of nearly 60% for the linear fog calculation case.
This commit is contained in:
parent
f54d9c0a61
commit
62285e0569
Notes:
sideshowbarker
2024-07-17 11:06:06 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/62285e0569 Pull-request: https://github.com/SerenityOS/serenity/pull/17504
2 changed files with 4 additions and 1 deletions
|
@ -1281,7 +1281,7 @@ ALWAYS_INLINE void Device::shade_fragments(PixelQuad& quad)
|
|||
f32x4 factor;
|
||||
switch (m_options.fog_mode) {
|
||||
case GPU::FogMode::Linear:
|
||||
factor = (m_options.fog_end - quad.fog_depth) / (m_options.fog_end - m_options.fog_start);
|
||||
factor = (m_options.fog_end - quad.fog_depth) * m_one_over_fog_depth;
|
||||
break;
|
||||
case GPU::FogMode::Exp: {
|
||||
auto argument = -m_options.fog_density * quad.fog_depth;
|
||||
|
@ -1555,6 +1555,8 @@ void Device::draw_statistics_overlay(Gfx::Bitmap& target)
|
|||
void Device::set_options(GPU::RasterizerOptions const& options)
|
||||
{
|
||||
m_options = options;
|
||||
if (m_options.fog_enabled)
|
||||
m_one_over_fog_depth = 1.f / (m_options.fog_end - m_options.fog_start);
|
||||
}
|
||||
|
||||
void Device::set_light_model_params(GPU::LightModelParameters const& lighting_model)
|
||||
|
|
|
@ -110,6 +110,7 @@ private:
|
|||
Vector<Triangle> m_triangle_list;
|
||||
Vector<Triangle> m_processed_triangles;
|
||||
Vector<GPU::Vertex> m_clipped_vertices;
|
||||
float m_one_over_fog_depth;
|
||||
Array<Sampler, GPU::NUM_TEXTURE_UNITS> m_samplers;
|
||||
bool m_samplers_need_texture_staging { false };
|
||||
Array<GPU::Light, NUM_LIGHTS> m_lights;
|
||||
|
|
Loading…
Reference in a new issue