mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 09:35:08 +00:00

Our move to floating point precision has eradicated the pixel artifacts in Quake 1, but introduced new and not so subtle rendering glitches in games like Tux Racer. This commit changes three things to get the best of both worlds: 1. Subpixel logic based on `i32` types was reintroduced, the number of bits is set to 6. This reintroduces the artifacts in Quake 1 but fixes rendering of Tux Racer. 2. Before triangle culling, subpixel coordinates are calculated and stored in `Triangle`. These coordinates are rounded, which fixes the Quake 1 artifacts. Tux Racer is unaffected. 3. The triangle area (actually parallelogram area) is also stored in `Triangle` so we don't need to recalculate it later on. In our previous subpixel code, there was a subtle disconnect between the two calculations (one with and one without subpixel precision) which resulted in triangles incorrectly being culled. This fixes some remaining Quake 1 artifacts.
28 lines
819 B
C++
28 lines
819 B
C++
/*
|
|
* Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibGPU/Config.h>
|
|
|
|
#define INCREASE_STATISTICS_COUNTER(stat, n) \
|
|
do { \
|
|
if constexpr (ENABLE_STATISTICS_OVERLAY) \
|
|
stat += (n); \
|
|
} while (0)
|
|
|
|
namespace SoftGPU {
|
|
|
|
static constexpr bool ENABLE_STATISTICS_OVERLAY = false;
|
|
static constexpr int MILLISECONDS_PER_STATISTICS_PERIOD = 500;
|
|
static constexpr int NUM_LIGHTS = 8;
|
|
static constexpr int SUBPIXEL_BITS = 6;
|
|
|
|
// See: https://www.khronos.org/opengl/wiki/Common_Mistakes#Texture_edge_color_problem
|
|
// FIXME: make this dynamically configurable through ConfigServer
|
|
static constexpr bool CLAMP_DEPRECATED_BEHAVIOR = false;
|
|
|
|
}
|