From fe36edf6ae4fa5d003ee60ce4d2fb755c59bec48 Mon Sep 17 00:00:00 2001 From: Stephan Unverwerth Date: Wed, 29 Dec 2021 21:59:13 +0100 Subject: [PATCH] LibSoftGPU: Put all constexpr config options into Config.h --- Userland/Libraries/LibSoftGPU/Config.h | 18 ++++++++++++++++++ Userland/Libraries/LibSoftGPU/Device.cpp | 5 ++--- Userland/Libraries/LibSoftGPU/Device.h | 5 ++--- Userland/Libraries/LibSoftGPU/Sampler.cpp | 5 +---- 4 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 Userland/Libraries/LibSoftGPU/Config.h diff --git a/Userland/Libraries/LibSoftGPU/Config.h b/Userland/Libraries/LibSoftGPU/Config.h new file mode 100644 index 0000000000..8a551ca40b --- /dev/null +++ b/Userland/Libraries/LibSoftGPU/Config.h @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2021, Stephan Unverwerth + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +namespace SoftGPU { + +static constexpr int RASTERIZER_BLOCK_SIZE = 8; +static constexpr int NUM_SAMPLERS = 32; + +// 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; + +} diff --git a/Userland/Libraries/LibSoftGPU/Device.cpp b/Userland/Libraries/LibSoftGPU/Device.cpp index 833224b5ea..f97d95b18b 100644 --- a/Userland/Libraries/LibSoftGPU/Device.cpp +++ b/Userland/Libraries/LibSoftGPU/Device.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include namespace SoftGPU { @@ -16,8 +17,6 @@ namespace SoftGPU { using IntVector2 = Gfx::Vector2; using IntVector3 = Gfx::Vector3; -static constexpr int RASTERIZER_BLOCK_SIZE = 8; - constexpr static int edge_function(const IntVector2& a, const IntVector2& b, const IntVector2& c) { return ((c.x() - a.x()) * (b.y() - a.y()) - (c.y() - a.y()) * (b.x() - a.x())); @@ -529,7 +528,7 @@ DeviceInfo Device::info() const return { .vendor_name = "SerenityOS", .device_name = "SoftGPU", - .num_texture_units = num_samplers + .num_texture_units = NUM_SAMPLERS }; } diff --git a/Userland/Libraries/LibSoftGPU/Device.h b/Userland/Libraries/LibSoftGPU/Device.h index 2456a2d89d..9fdd2803ee 100644 --- a/Userland/Libraries/LibSoftGPU/Device.h +++ b/Userland/Libraries/LibSoftGPU/Device.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -66,8 +67,6 @@ struct RasterizerOptions { Array texcoord_generation_config {}; }; -inline static constexpr size_t const num_samplers = 32; - class Device final { public: Device(const Gfx::IntSize& min_size); @@ -101,7 +100,7 @@ private: Vector m_triangle_list; Vector m_processed_triangles; Vector m_clipped_vertices; - Array m_samplers; + Array m_samplers; }; } diff --git a/Userland/Libraries/LibSoftGPU/Sampler.cpp b/Userland/Libraries/LibSoftGPU/Sampler.cpp index 0a86f22391..1600f356bd 100644 --- a/Userland/Libraries/LibSoftGPU/Sampler.cpp +++ b/Userland/Libraries/LibSoftGPU/Sampler.cpp @@ -4,16 +4,13 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include namespace SoftGPU { -// 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; - static constexpr float fracf(float value) { return value - floorf(value);