mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibGL: Use 8x8 block size in SoftwareRasterizer
This smaller block size allows us to use an `u8` for the pixel mask during triangle rasterization. These changes result in better FPS in 3DFileViewer, which periodically shoots up to 250-300 FPS on my machine. Before, the peaks were somewhere in the range of 160-170 FPS.
This commit is contained in:
parent
5a649d0fd5
commit
f201567153
Notes:
sideshowbarker
2024-07-17 22:34:13 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/f201567153b Pull-request: https://github.com/SerenityOS/serenity/pull/11236 Reviewed-by: https://github.com/bgianfo Reviewed-by: https://github.com/sunverwerth ✅
@ -15,7 +15,7 @@ namespace GL {
|
|||||||
using IntVector2 = Gfx::Vector2<int>;
|
using IntVector2 = Gfx::Vector2<int>;
|
||||||
using IntVector3 = Gfx::Vector3<int>;
|
using IntVector3 = Gfx::Vector3<int>;
|
||||||
|
|
||||||
static constexpr int RASTERIZER_BLOCK_SIZE = 16;
|
static constexpr int RASTERIZER_BLOCK_SIZE = 8;
|
||||||
|
|
||||||
constexpr static int edge_function(const IntVector2& a, const IntVector2& b, const IntVector2& c)
|
constexpr static int edge_function(const IntVector2& a, const IntVector2& b, const IntVector2& c)
|
||||||
{
|
{
|
||||||
@ -199,8 +199,8 @@ static void rasterize_triangle(const RasterizerOptions& options, Gfx::Bitmap& re
|
|||||||
int const by1 = (min(render_bounds.bottom(), max(max(v0.y(), v1.y()), v2.y())) + block_padding) / RASTERIZER_BLOCK_SIZE;
|
int const by1 = (min(render_bounds.bottom(), max(max(v0.y(), v1.y()), v2.y())) + block_padding) / RASTERIZER_BLOCK_SIZE;
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
static_assert(RASTERIZER_BLOCK_SIZE < sizeof(int) * 8, "RASTERIZER_BLOCK_SIZE must be smaller than the pixel_mask's width in bits");
|
u8 pixel_mask[RASTERIZER_BLOCK_SIZE];
|
||||||
int pixel_mask[RASTERIZER_BLOCK_SIZE];
|
static_assert(RASTERIZER_BLOCK_SIZE <= sizeof(decltype(*pixel_mask)) * 8, "RASTERIZER_BLOCK_SIZE must be smaller than the pixel_mask's width in bits");
|
||||||
|
|
||||||
FloatVector4 pixel_buffer[RASTERIZER_BLOCK_SIZE][RASTERIZER_BLOCK_SIZE];
|
FloatVector4 pixel_buffer[RASTERIZER_BLOCK_SIZE][RASTERIZER_BLOCK_SIZE];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user