18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 23:17:56 +01:00
Commit Graph

10 Commits

Author SHA1 Message Date
Hirek 48b7c679a0 Windscreen snow: no crash of the simulator when the driver's compiler faults
A player's simulator (Vulkan, GeForce RTX 4060, NVIDIA 610.88, through Steam) crashed at every start
as the cab loaded: an access violation (read of address 8) inside nvgpucomp64.dll while
vkCreateComputePipelines compiled water_snowlayer.comp. The crash came on $baltyk_skm1.scn and $td.scn
alike, at the same address in the driver.

The snow shaders (shaders/vk14 and shaders/ogl46, the same in both) no longer use what the
compute shader alone had: a vector component written at an index known only while running through an
inout parameter (snRef), constant arrays of structs and of ints indexed at run time (sn_grids,
sn_lump_tiles, the neighbours of snSpan) and a local vec4 indexed by the blade. They are worked out by
small functions and explicit components instead (snRefPut, snRefWord, snGrid, snLumpTile, snNear),
and the blade is read from the storage as water_snow.comp, which the same driver compiled, does.
The results are the same. glslc compiles both variants and spirv-val passes; whether 610.88 compiles
them now can't be checked without that driver.

So that a driver crashing on a program the renderer can go without doesn't take the simulator down,
the programs of the windscreen water are made under gfx::DriverCrashGuard
(rendering/common/drivercrashguard.*):
- with msvc the fault of the driver is caught (SEH) and the session goes on without the program: the
  glasses without the snow, or without the simulation of the water;
- the program is written down in the cache of the renderer (driver_crash_attempt.txt) before the driver
  gets it and crossed out after. a program a session ended on is suspect (driver_crash_suspects.txt);
  when a second session ends on it, or when a fault was caught, it is recorded (driver_crashes.txt) and
  not made again with that driver. a new driver or a changed program is tried again;
- Vulkan makes these pipelines without the VkPipelineCache, whose lock a faulting driver might leave
  taken (the drivers keep their own cache on the disk).

Tested: unit tests (1211/1211, with a caught access violation), Vulkan and OpenGL 4.6 in the cab of
303E on $td.scn (RTX 4070, 621.14), and on Vulkan with a real access violation injected into the
pipeline of water_snowlayer.comp: the session went on without the snow, the next one skipped it.

No change of the game data.
2026-11-30 19:39:29 +01:00
Claude 5d6f443450 Review 28.11: rain cells always bound, the velocity target and the blur pass only when needed
- the cells of the rain: the opengl renderer makes their storage (cleared) with the first bind and keeps it
  bound, the glasses read the cells only when they were worked out in the frame (scene_ubs.rain_state.w,
  both renderers): never the storage before the first rain, nor the stand-in of the vulkan renderer
- the pass of the motion blur and (opengl) the velocities drawn only in the frames which need them: the
  motion blur with something moving, the taa, or a glass of the rain, the insects or the snow in the view
  (windscreen_water::wants_glass_requests(): the cab seen from inside has one, or the view is not from the
  cab). the glasses keep their drops and haze with the motion blur off, the motion is blurred by 0 then

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
2026-11-29 12:53:29 +01:00
Claude 160e8b8a46 Windscreen water: the review of 27.11 (the snow list stops when full, the cells of the rain only for a cab with a glass of the rain)
- snList() stops listing when its SN_REFS are taken: no lumps worked out for nothing, and the cover of the texel counts only the
  sprites the glass lays (no gaps where it took the dropped ones for covering); OpenGL 4.6 and Vulkan
- update_rain_cells() gets no rain for a cab without a material of the shader of the rain in this weather
  (windscreen_water::wants_rain_cells(); as before when the simulation isn't used)
- Vulkan: a rain-cell buffer which can't be made leaves the glasses with rain dry (a small stand-in the pass sets hold) instead of
  failing the whole windscreen water; it is still made at the start, since the pass sets and those of the cullings hold it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
2026-11-29 11:39:15 +01:00
Claude 05be4bff29 Windscreen water: the passes of the snow are optional
A snow kernel that doesn't compile (as water_snow.comp did on NVIDIA) leaves the glasses of the snow clear and the rain working, instead of disabling the whole simulation (OpenGL 4.6 and Vulkan).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
2026-11-29 11:39:15 +01:00
lcddisplay 3de73b0e85 Windscreen snow: the layer over the rectangle of the glass, one for the cab
The layer of 1024 x 1024 texels over the whole uv gave a glass taking a part
of its texture too few of them (the EP09 104ec: ~470 across the glass, 1.8
pixels of the screen a texel at 1080p), so the lumps came out soft. Now the
layer lies over the rectangle of the uv the glass takes, its 2M texels across
and down as the glass is wide and high (~1 mm a texel); the renderer works
it out from the map of the glass when it sets the glass up and puts it in
the storage (water.glsl, water_layer_rect).

One layer, for the first glass of the snow of the cab (a cab has one as a
rule); a second one lays its snow at every pixel as before the layer, the
same look, slower. The storage of the water: 58 MiB before the layers,
82 MiB now (106 MiB with the four layers of 1024 x 1024).

No assets change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
2026-11-29 11:39:13 +01:00
lcddisplay 02a0de85c2 Windscreen snow: lay the sprites into a layer of the glass, the glass only reads it
The glass of the snow laid its nine grids of lumps (81 cells) and its flakes
at every pixel in every frame, ~6-9 ms of the GPU at 1080p. Now a compute
pass (water_snowlayer.comp, the sprites in snow_sprites.glsl) lays the snow
of a glass into a layer of 1024 x 1024 texels over its uv after the step of
the snow: a band of every 8th row in a step (the snow under a lump changes
slowly) and at once wherever a blade went over the glass. The glass reads
the layer filtered (mat_snow_windscreen.frag), as the glass of the rain
reads its cells. Laid front to back: a texel stops once the snow over it
covers it, and a cell reads the map only when its sprite reaches the texel.

The storage of the water grows by the layers, 12 MiB for each of the four
glasses. The look stays as it was.

No assets change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
2026-11-29 11:39:13 +01:00
lcddisplay ba3129275c Snow windscreen: the snow of the glass simulated on a map that keeps it
A glass of mat_snow_windscreen (the material of the "snow:" block, with a
mask of the wipers) gets a slot of the windscreen water storage, as the
glasses of the water could, and two maps of its snow (a step reads one,
writes the other): the snow, the water, how packed the snow is and the shape
of its flakes for each of 256 x 256 texels of its uv. water_snow.comp runs a
step a frame, both APIs:
- the flakes land as many as come to the glass facing the snow against the
  cab (and a few from the eddies), the dry ones bouncing off at speed;
- the blades take the snow they go over (a little stays, a wet trace) and
  push it ahead of themselves, leaving it as ridges at the ends of their
  sweeps; piled snow slips onto its neighbours into a wedge;
- the glass is warmer than the air (the cab is heated, less so at speed):
  above zero the snow melts into water, slush slides down, dry powder is
  blown along by the air at speed, the water runs and dries.
mat_snow_windscreen.frag draws the map: flakes from the atlas where the snow
is thin (water spots where it melted), a layer with a torn edge, as opaque as
it is thick, grey when wet, its relief from the slopes of the map; the wet
glass bends the picture behind through the post-processing. Without the
simulation the glass is drawn as before.

The glasses are found again when a material of the cab changes its kind
(the weather switched its shader). The drop passes run only for glasses of
the water. No assets change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
2026-11-29 11:39:10 +01:00
Claude 91d5851ea4 Rain windscreen: a glass looks only at the drops which reach the quarter of its cell
A second pass of rain_cells.comp writes, for every drop cell, which of the drops of the 9 cells around reach each quarter of
it, so a pixel looks at those (usually 1 to 3) instead of all 9. The bias of the drop sizes is applied there too, and the
glass keeps fewer values through its loops (the frame of the glass and the lens are worked out after them, the rivulet of
the pixel is read again where it is needed), so more pixels run at once. The look is the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
2026-11-29 11:39:09 +01:00
Claude 394e252daf Rain windscreen: the cells of the drops and rivulets worked out once a frame
The glass with rain worked out, in every pixel, the hashes and the life cycles of the 9 drop cells around it, of the rivulet
cells of its 5 layers and of those the drops are swept by. A compute pass (rain_cells.comp) now does it once a frame for every
cell into a buffer (rain_cells.glsl: RAIN_CELLS_SSBO in the pass set of Vulkan 1.4, binding 18 in OpenGL 4.6); the glass only
reads it, and asks the wipers only for the drops the pixel lies on. The hashes are the same, so the drops and the rivulets
are where they were.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
2026-11-29 11:39:09 +01:00
Hirek 719c729929 Improve rain shader 2026-10-26 15:51:56 +01:00