Commit Graph
23 Commits
Author SHA1 Message Date
Anders Jenbo 005e7dcc23 chore: clang-tidy cleanup part 1 2026-04-03 22:57:48 +02:00
Anders Jenbo 1c76897f2c Apply simple const rules using clang-tidy 2025-08-16 01:21:36 +02:00
Stephen C. Wills 0b4f3b4732 Introduce subtile lighting into the software renderer (#7807) 2025-03-04 09:29:53 -05:00
Gleb Mazovetskiy d7647d6c63 More dependency untangling
1. Moves more assets-related stuff from `init` to `engine/assets`.
2. Removes `SDL_audiolib` dependency from `soundsample.h`.
3. Cleans up some unused/missing includes.
2025-01-09 18:19:44 +00:00
staphen b78ec23362 Fix bounds check in RenderClxOutline() 2024-09-24 14:34:33 +02:00
Eric Robinson 96a2a145e2 Increase MaxOutlinePixels 2024-09-01 07:27:52 +01:00
Gleb Mazovetskiy dc2406d2b1 Further increase outline pixels to 2048
Follow-up to https://github.com/diasurgical/devilutionX/pull/7157
2024-08-16 20:49:39 +01:00
Gleb Mazovetskiy efa94307e0 Optimize lit blending with light level 0
We don't need to worry about the custom Hell light table here (#7166)
because this change only affects CLX sprites, not dungeon tiles.
2024-08-11 15:16:24 +01:00
Gleb Mazovetskiy 7940a10da9 clx_render: Slightly optimize GetSkipSize
This gives a very slight FPS boost.
1140 to 1143 FPS on my machine as measured by:

```bash
tools/linux_reduced_cpu_variance_run.sh tools/measure_timedemo_performance.py -n 5 --binary build-rel/devilutionx
```
2024-08-10 21:46:29 +01:00
Gleb Mazovetskiy 8a135c9c3b Increase OutlinePixels limit from 1024 to 1536
@Trihedraf reported that the game crashed when killing Diablo.

1536 should be enough for Diablo and any custom sprites (if not, we can increase it further).
2024-06-23 18:22:06 +01:00
Gleb Mazovetskiy b6347fb194 clx_render: Further simplify outline rendering
1. Switches to uint8_t for coordinate storage.
2. Avoids producing duplicate pixels.
2024-06-16 18:15:22 +01:00
Gleb Mazovetskiy 2e7d565b05 CLX renderer: Cache the last drawn outline 2024-06-16 16:14:16 +02:00
Gleb Mazovetskiy ee8ca1c005 Greatly simplify outline rendering
The new algorithm is a lot less code, slightly faster, and results
in a smaller binary (-40 KiB on rg99).

The previous algorithm filled all the pixels around every solid pixel.
The new algorithm only fills pixels that will be visible.

We first collect the outline pixels into an array (which may contain a
small amount of duplicates). Then, we render the entire array in a
single loop. This turns out to be slightly faster than rendering inline,
at the cost of ~4 KiB of stack (basically free).

To collect the pixels, we go through the CLX sprite, keeping track
of the solid runs in the current row, and the filled pixels on the line
above and the line below.

To be able to quickly test the pixels above and below, we introduce a
new data structure, `StaticBitVector`. It is similar to a bitset,
except the size is determined at runtime (capacity is fixed),
and it supports quick updates of entire subspans.
2024-06-16 16:14:16 +02:00
Gleb Mazovetskiy bae4030d7b Simplify CLX rendering
Inlines blit command parsing.

We previously had blit commands because we supported rendering multiple
formats (CEL, CL2, CLX) but now we only ever render CLX, so this is
no longer necessary.
2024-06-10 22:33:05 +01:00
obligaron 95940a4c7e Fix MSVC warnings in engine\render\* 2023-11-08 17:03:19 +01:00
Gleb Mazovetskiy b64ee0e190 Use if constexpr in clx/dun_render 2023-09-10 10:22:19 +01:00
obligaron f59e3aaffb Introduce IsPointWithinClx 2023-08-12 17:47:31 +02:00
Gleb Mazovetskiy d8cd147ac7 Re-encode CL2 on load
Original Blizzard encoder is slightly less optimal than our encoder.

While size in RAM in less of a concern for the non-`UNPACKED_MPQS`
build, smaller files are faster to render.

Savings for unpacked and minified MPQs:
* diabdat.mpq: 918,311 bytes.
* hellfire.mpq: 313,882 bytes.

Example player graphics (note that only a few are loaded at any given time for single player):
* diabdat/plrgfx/warrior/: 366,564 bytes.

Example monster graphics savings:

* diabdat/monsters/skelbow: 5,391 bytes.

Based on the implementation from https://github.com/diasurgical/devilutionx-graphics-tools/pull/6
2023-07-13 01:44:16 +01:00
Gleb Mazovetskiy 14ce84b056 Fix CLX outline clipped rendering on the right
The actual fix is the diff in `RenderClxOutlineRowClipped`.
The rest is a refactorings that make the code easier to
follow.

Fixes #6199
2023-07-11 09:08:51 +01:00
Gleb Mazovetskiy 5bf0b8bc96 Add more missing <cstdint> includes
https://github.com/diasurgical/devilutionX/pull/6095 only added includes
for `uint32_t`, this PR also adds the includes for the remaining
integral types.
2023-05-10 16:29:27 +01:00
Gleb Mazovetskiy ac0627f029 Add a debug function that describes a CLX
Example output (also demonstrates a bug in our encoder):

CLX sprite: 16x20 pixelDataSize=97b

command | width | bytes | color(s)
--------|------:|------:|---------
Transp. |    80 |     1 |
Pixels  |     2 |     3 | 203 199
Fill    |     3 |     2 | 202
Pixels  |     2 |     3 | 199 201
Fill    |     1 |     2 | 205
Transp. |     8 |     1 |
Pixels  |     3 |     4 | 205 199 196
Fill    |     4 |     2 | 197
Fill    |     1 |     2 | 202
Transp. |     9 |     1 |
Pixels  |     6 |     7 | 206 199 197 203 206 202
Fill    |     1 |     2 | 204
Transp. |    10 |     1 |
Pixels  |     4 |     5 | 206 199 197 205
Fill    |     1 |     2 | 207
Transp. |    12 |     1 |
Pixels  |     3 |     4 | 206 197 197
Fill    |     1 |     2 | 205
Transp. |     9 |     1 |
Pixels  |     7 |     8 | 207 205 203 206 206 197 197
Fill    |     1 |     2 | 206
Transp. |     8 |     1 |
Pixels  |     3 |     4 | 204 197 199
Fill    |     1 |     2 | 205
Transp. |     1 |     1 |
Pixels  |     2 |     3 | 202 197
Fill    |     1 |     2 | 204
Transp. |     8 |     1 |
Pixels  |     7 |     8 | 206 197 199 207 206 199 196
Fill    |     1 |     2 | 205
Transp. |     9 |     1 |
Pixels  |     1 |     2 | 203
Fill    |     4 |     2 | 197
Fill    |     1 |     2 | 202
Transp. |    10 |     1 |
Pixels  |     5 |     6 | 207 205 199 199 203
Fill    |     1 |     2 | 207
Transp. |    89 |     1 |
2023-04-11 08:50:07 +02:00
Gleb Mazovetskiy 0f0f57080c render: Move common_impl.h into clx_render.cpp
We no longer have other renderers.
2022-08-03 02:38:55 +02:00
Gleb Mazovetskiy 961866e1c4 CLX: A new graphics format
The format is almost identical to CL2, except it uses the frame header
to store frame width and height instead of 5 32-line offsets.

This means we always have access to frame dimensions, so we can use it
as an on-disk format for our graphics as well.

Additionally, we may be able to optimize the rendering even more
in the future now that we have guaranteed knowledge of frame dimensions.
2022-08-03 02:38:55 +02:00