mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:27:45 +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
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue