summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibSoftGPU
AgeCommit message (Collapse)Author
2023-02-18LibSoftGPU: Use multiplication instead of division for linear fogJelle Raaijmakers
Sampling profiling shows a reduction of nearly 60% for the linear fog calculation case.
2023-02-18LibSoftGPU: Use `AK::SIMD::exp_approximate` instead of `::exp`Jelle Raaijmakers
The approximate version is properly vectorized and results in fewer stalls than the `::exp` version.
2023-02-02LibSoftGPU: Only enable texture stages if requiredJelle Raaijmakers
Copying over every texel (4x`f32x4`) for every texture unit is relatively expensive. By checking if we even need to remember these texel values, we reduce the time spent in `rasterize_triangle` by around 2% as measured in Quake III.
2023-02-02LibSoftGPU: Make blending simpler and more efficientJelle Raaijmakers
Previously, we would precalculate "alpha blend factors" on every configuration update and then calculate the source and destination blending factors in one go using all these factors. The idea here was probably that we would get better performance by avoiding branching. However, by measuring blending performance in Quake III, it seems that this simpler version that only calculates the required factors reduces the CPU time spent in `rasterize_triangle` by 3%. As a bonus, `GL_SRC_ALPHA_SATURATE` is now also implemented.
2023-01-30LibSoftGPU: Remove DeprecatedString usageJelle Raaijmakers
2023-01-28AK: Remove `try_` prefix from FixedArray creation functionsLinus Groh
2023-01-26LibGfx: Remove `try_` prefix from bitmap creation functionsTim Schumacher
Those don't have any non-try counterpart, so we might as well just omit it.
2023-01-09LibSoftGPU: Remove workaround for i686 depth comparisonJelle Raaijmakers
2023-01-07Userland: Silence warnings from ElapsedTimer::elapsed() type changeAndrew Kaster
We changed elapsed() to return i64 instead of int as that's what AK::Time::to_milliseconds() returns, causing a bunch of implicit lossy conversions in callers. Clean those up with a mix of type changes and casts.
2022-12-26LibGPU+LibSoftGPU: Move size and pixel format information to GPU::ImageStephan Unverwerth
Size and format information are the same for every implementation and do not need to be virtual. This removes the need to reimplement them for each driver.
2022-12-17LibSoftGPU: Delegate shader creation to new class ShaderCompilerStephan Unverwerth
2022-12-17LibSoftGPU: Implement shader processor for SoftGPU ISAStephan Unverwerth
This adds a shader processor that executes our ISA when a fragment shader is currently bound to the device.
2022-12-17LibSoftGPU: Define a simple shader instruction setStephan Unverwerth
This adds a simple instruction set with basic operations and adds an instruction list to the shader class.
2022-12-17LibSoftGPU: Make output in PixelQuad genericStephan Unverwerth
Same as with inputs, we define outputs as a generic array of floats. This can later be expanded to accomodate multiple render targets or vertex attributes in the case of a vertex shader.
2022-12-17LibSoftGPU: Make input in PixelQuad genericStephan Unverwerth
Previously we would store vertex color and texture coordinates in separate fields in PixelQuad. To make them accessible from shaders we need to store them as a completely generic array of floats.
2022-12-17LibSoftGPU: Allow binding a fragment shaderStephan Unverwerth
2022-12-17LibGL+LibSoftGPU: Add GPU side shader infrastructureStephan Unverwerth
This adds a shader class to LibSoftGPU and makes use of it when linking GLSL program in LibGL. Also adds actual rendering code to the shader tests.
2022-12-07Meta+Userland: Pass Gfx::IntSize by valueMacDue
Just two ints like Gfx::IntPoint.
2022-12-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-12-03Everywhere: Run clang-formatLinus Groh
2022-11-01Everywhere: Mark dependencies of most targets as PRIVATETim Schumacher
Otherwise, we end up propagating those dependencies into targets that link against that library, which creates unnecessary link-time dependencies. Also included are changes to readd now missing dependencies to tools that actually need them.
2022-10-19LibSoftGPU: Call `floor_int_range` only once in `sample_2d_lod`Jelle Raaijmakers
We were invoking `frac_int_range` twice to get the `alpha` and `beta` values to interpolate between 4 texels, but these call into `floor_int_range` again. Let's not repeat the work.
2022-10-19LibSoftGPU: Extract `argb32_color` value in rasterizationJelle Raaijmakers
This makes it easier to correlate slow instructions in the disassembly view of ProfileViewer.
2022-10-19LibSoftGPU: Make alpha testing a static functionJelle Raaijmakers
There is no need to access the Device's members for alpha testing; pass in the required alpha function and reference value.
2022-10-19LibSoftGPU: Clean up `Sampler` importsJelle Raaijmakers
2022-10-19LibSoftGPU: Drop texel Z coordinate from `Sampler`Jelle Raaijmakers
We only support 2D indexing into textures at the moment, so don't perform any work trying to support the Z coordinate.
2022-10-19LibGL+LibGPU+LibSoftGPU: Report maximum texture sizecflip
2022-09-18Libraries: Add missing includes, add namespace qualifiersBen Wiederhake
This remained undetected for a long time as HeaderCheck is disabled by default. This commit makes the following file compile again: // file: compile_me.cpp #include <LibDNS/Question.h> // That's it, this was enough to cause a compilation error. Likewise for most other files touched by this commit.
2022-09-16LibC: Remove the LibM interface targetTim Schumacher
2022-09-14LibSoftGPU: Return a `const&` texel in `Image` to prevent copyingJelle Raaijmakers
On every texel access, some floating point instructions involved in copying 4 floats popped up. Let `Image::texel() const` return a `FloatVector4 const&` to prevent these operations. This results in a ~7% FPS increase in GLQuake on my machine.
2022-09-14LibSoftGPU: Use `memcpy` instead of a loop to blit the color bufferJelle Raaijmakers
Looking at `Tubes` before and after this change, comparing the original loop to the one using `memcpy`, including the time for `memcpy` itself, resulted in ~15% fewer samples in profiles on my machine.
2022-09-13LibSoftGPU: Reduce subpixel precision from 6 to 4 bitsJelle Raaijmakers
With 6 bits of precision, the maximum triangle coordinate we can handle is sqrt(2^31 / (1 << 6)^2) = ~724. Rendering to a target of 800x600 or higher quickly becomes a mess because of integer overflow. By reducing the subpixel precision to 4 bits, we support coordinates up to ~2896, which means that we can (try to) render to target sizes like 2560x1440. This fixes the main menu backdrop for the Half-Life port. It also introduces more white pixel artifacts in Quake's water / lava rendering, but this is a level geometry visualization bug (see `r_novis`).
2022-09-13LibGL: Implement `GL_TEXTURE_LOD_BIAS` for texture objectsJelle Raaijmakers
2022-09-11LibGL+LibGPU+LibSoftGPU: Report texture clamp to edge supportJelle Raaijmakers
2022-09-11LibSoftGPU: Divide texture coordinates by QJelle Raaijmakers
Up until now, we have only dealt with games that pass Q = 1 for their texture coordinates. PrBoom+, however, relies on proper homogenous texture coordinates for its relatively complex sky rendering, which means that we should perform this per-fragment division.
2022-09-11LibGL+LibGPU+LibSoftGPU: Implement matrix stack per texture unitJelle Raaijmakers
Each texture unit now has its own texture transformation matrix stack. Introduce a new texture unit configuration that is synced when changed. Because we're no longer passing a silly `Vector` when drawing each primitive, this results in a slightly improved frames per second :^)
2022-09-11LibGL+LibGPU+LibSoftGPU: Implement `GL_GENERATE_MIPMAP`Jelle Raaijmakers
We can now generate texture mipmaps on the fly if the client requests it. This fixes the missing textures in our PrBoom+ port.
2022-09-11LibGL+LibGPU+LibSoftGPU: Remove concept of `layer` in favor of `depth`Jelle Raaijmakers
Looking at how Khronos defines layers: https://www.khronos.org/opengl/wiki/Array_Texture We both have 3D textures and layers of 2D textures, which can both be encoded in our existing `Typed3DBuffer` as depth. Since we support depth already in the GPU API, remove layer everywhere. Also pass in `Texture2D::LOG2_MAX_TEXTURE_SIZE` as the maximum number of mipmap levels, so we do not allocate 999 levels on each Image instantiation.
2022-09-11LibGL+LibGPU+LibSoftGPU: Implement `glCopyTex(Sub)?Image2d`Jelle Raaijmakers
These two methods copy from the frame buffer to (part of) a texture.
2022-09-11LibGL+LibGPU+LibSoftGPU: Rename `blit_color_buffer_to`Jelle Raaijmakers
This makes it consistent with our other `blit_from_color_buffer` and paves the way for a third method that will be introduced in one of the next commits.
2022-09-11LibGL+LibSoftGPU: Implement fixed pipeline support for `GL_COMBINE`Jelle Raaijmakers
`GL_COMBINE` is basically a fixed function calculator to perform simple arithmetics on configurable fragment sources. This patch implements a number of texture env parameters with support for the RGBA internal format.
2022-09-11LibSoftGPU: Convert width and height to `f32x4` just onceJelle Raaijmakers
We were passing along a `u32x4` only for it to be converted to `f32x4` as soon as we'd use it.
2022-09-11LibSoftGPU: Remove unused alias `truncate_int_range`Jelle Raaijmakers
2022-09-08LibSoftGPU: Use approximation for maximum depth slopeJelle Raaijmakers
OpenGL allows GPUs to approximate a triangle's maximum depth slope which prevents a number computationally expensive instructions. On my machine, this gives me +6% FPS in Quake III. We are able to reuse `render_bounds` here since it is the containing rect of the (X, Y) window coordinates of the triangle, thus its width and height are the maximum delta X and delta Y, respectively.
2022-08-28LibGL+LibGPU+LibSoftGPU: Report texture env add extensionJelle Raaijmakers
The Quake 3 port makes use of this extension to determine a more efficient multitexturing strategy. Since LibSoftGPU supports it, let's report the extension in LibGL. :^)
2022-08-27LibGL+LibGPU+LibSoftGPU: Implement texture pixel format supportJelle Raaijmakers
In OpenGL this is called the (base) internal format which is an expectation expressed by the client for the minimum supported texel storage format in the GPU for textures. Since we store everything as RGBA in a `FloatVector4`, the only thing we do in this patch is remember the expected internal format, and when we write new texels we fixate the value for the alpha channel to 1 for two formats that require it. `PixelConverter` has learned how to transform pixels during transfer to support this.
2022-08-27LibGPU+LibSoftGPU: Add PixelFormat::IntensityJelle Raaijmakers
2022-08-27LibGL+LibGPU+LibSoftGPU: Implement flexible pixel format conversionJelle Raaijmakers
A GPU (driver) is now responsible for reading and writing pixels from and to user data. The client (LibGL) is responsible for specifying how the user data must be interpreted or written to. This allows us to centralize all pixel format conversion in one class, `LibSoftGPU::PixelConverter`. For both the input and output image, it takes a specification containing the image dimensions, the pixel type and the selection (basically a clipping rect), and converts the pixels from the input image to the output image. Effectively this means we now support almost all OpenGL 1.5 formats, and all custom logic has disappeared from: - `glDrawPixels` - `glReadPixels` - `glTexImage2D` - `glTexSubImage2D` The new logic is still unoptimized, but on my machine I experienced no noticeable slowdown. :^)
2022-08-27LibSoftGPU: Make `ownership_token` type in `Image` consistentJelle Raaijmakers
This is now the same as defined in `GPU::Image`.