mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09: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: 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;
|
f32x4 factor;
|
||||||
switch (m_options.fog_mode) {
|
switch (m_options.fog_mode) {
|
||||||
case GPU::FogMode::Linear:
|
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;
|
break;
|
||||||
case GPU::FogMode::Exp: {
|
case GPU::FogMode::Exp: {
|
||||||
auto argument = -m_options.fog_density * quad.fog_depth;
|
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)
|
void Device::set_options(GPU::RasterizerOptions const& options)
|
||||||
{
|
{
|
||||||
m_options = 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)
|
void Device::set_light_model_params(GPU::LightModelParameters const& lighting_model)
|
||||||
|
|
|
@ -110,6 +110,7 @@ private:
|
||||||
Vector<Triangle> m_triangle_list;
|
Vector<Triangle> m_triangle_list;
|
||||||
Vector<Triangle> m_processed_triangles;
|
Vector<Triangle> m_processed_triangles;
|
||||||
Vector<GPU::Vertex> m_clipped_vertices;
|
Vector<GPU::Vertex> m_clipped_vertices;
|
||||||
|
float m_one_over_fog_depth;
|
||||||
Array<Sampler, GPU::NUM_TEXTURE_UNITS> m_samplers;
|
Array<Sampler, GPU::NUM_TEXTURE_UNITS> m_samplers;
|
||||||
bool m_samplers_need_texture_staging { false };
|
bool m_samplers_need_texture_staging { false };
|
||||||
Array<GPU::Light, NUM_LIGHTS> m_lights;
|
Array<GPU::Light, NUM_LIGHTS> m_lights;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue