mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:47:45 +00:00
LibSoftGPU: Move alpha test into separate function
This commit is contained in:
parent
68a1727547
commit
941e9d9922
2 changed files with 37 additions and 24 deletions
|
@ -29,6 +29,7 @@ static long long g_num_quads;
|
|||
using IntVector2 = Gfx::Vector2<int>;
|
||||
using IntVector3 = Gfx::Vector3<int>;
|
||||
|
||||
using AK::SIMD::any;
|
||||
using AK::SIMD::exp;
|
||||
using AK::SIMD::expand4;
|
||||
using AK::SIMD::f32x4;
|
||||
|
@ -401,30 +402,8 @@ void Device::rasterize_triangle(const Triangle& triangle)
|
|||
|
||||
shade_fragments(quad);
|
||||
|
||||
if (m_options.enable_alpha_test && m_options.alpha_test_func != AlphaTestFunction::Always) {
|
||||
switch (m_options.alpha_test_func) {
|
||||
case AlphaTestFunction::Less:
|
||||
quad.mask &= quad.out_color.w() < m_options.alpha_test_ref_value;
|
||||
break;
|
||||
case AlphaTestFunction::Equal:
|
||||
quad.mask &= quad.out_color.w() == m_options.alpha_test_ref_value;
|
||||
break;
|
||||
case AlphaTestFunction::LessOrEqual:
|
||||
quad.mask &= quad.out_color.w() <= m_options.alpha_test_ref_value;
|
||||
break;
|
||||
case AlphaTestFunction::Greater:
|
||||
quad.mask &= quad.out_color.w() > m_options.alpha_test_ref_value;
|
||||
break;
|
||||
case AlphaTestFunction::NotEqual:
|
||||
quad.mask &= quad.out_color.w() != m_options.alpha_test_ref_value;
|
||||
break;
|
||||
case AlphaTestFunction::GreaterOrEqual:
|
||||
quad.mask &= quad.out_color.w() >= m_options.alpha_test_ref_value;
|
||||
break;
|
||||
case AlphaTestFunction::Never:
|
||||
case AlphaTestFunction::Always:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
if (m_options.enable_alpha_test && m_options.alpha_test_func != AlphaTestFunction::Always && !test_alpha(quad)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Write to depth buffer
|
||||
|
@ -817,6 +796,39 @@ ALWAYS_INLINE void Device::shade_fragments(PixelQuad& quad)
|
|||
}
|
||||
}
|
||||
|
||||
ALWAYS_INLINE bool Device::test_alpha(PixelQuad& quad)
|
||||
{
|
||||
auto const alpha = quad.out_color.w();
|
||||
auto const ref_value = expand4(m_options.alpha_test_ref_value);
|
||||
|
||||
switch (m_options.alpha_test_func) {
|
||||
case AlphaTestFunction::Less:
|
||||
quad.mask &= alpha < ref_value;
|
||||
break;
|
||||
case AlphaTestFunction::Equal:
|
||||
quad.mask &= alpha == ref_value;
|
||||
break;
|
||||
case AlphaTestFunction::LessOrEqual:
|
||||
quad.mask &= alpha <= ref_value;
|
||||
break;
|
||||
case AlphaTestFunction::Greater:
|
||||
quad.mask &= alpha > ref_value;
|
||||
break;
|
||||
case AlphaTestFunction::NotEqual:
|
||||
quad.mask &= alpha != ref_value;
|
||||
break;
|
||||
case AlphaTestFunction::GreaterOrEqual:
|
||||
quad.mask &= alpha >= ref_value;
|
||||
break;
|
||||
case AlphaTestFunction::Never:
|
||||
case AlphaTestFunction::Always:
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
return any(quad.mask);
|
||||
}
|
||||
|
||||
void Device::resize(const Gfx::IntSize& min_size)
|
||||
{
|
||||
wait_for_all_threads();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue