18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 22:07:55 +01:00
Commit Graph

4642 Commits

Author SHA1 Message Date
Hirek ddaef9a3a4 Merge pull request #572 from MaSzyna-EU07/fix/vulkan-early-cab-depth
fix(vulkan): the cab drawn early writes all of its depth again
2026-11-30 19:57:15 +00:00
Hirek 0409591b72 fix(vulkan): the cab drawn early writes all of its depth again
Without rain or snow the colour pass draws the cab first (9b7d02e5). Since
the depth of the prepass is kept for the alpha tested draws (ff2ff308),
the cab drawn first fell under that too: its screens, stickers and desk
lamps wrote no depth of their own, and what came after them, the scene and
the simplified desk (cab1) of the outer model a few centimetres behind,
came through in patches cut along the triangles. The released exe shows it
as well.

The early cab now writes its depth, as in the rain and in the OpenGL
renderer; the rest of the scene keeps the depth of the prepass as before.
build-fix-vulkan-early-cab-depth
2026-11-30 20:51:52 +01:00
Hirek a98005cfaf Merge pull request #570 from MaSzyna-EU07/fix/vulkan-kept-depth-decals
fix(vulkan): stickers on vehicles no longer vanish behind the body seen at an angle
2026-11-30 19:10:33 +00:00
Hirek ae2ce61e9a fix(vulkan): stickers on vehicles no longer vanish behind the body seen at an angle
With the depth prepass of the scene, the colour pass of the alpha tested
materials (default, normalmap, pbr, ...) doesn't write the depth the prepass
drew (keepdepth) and tested it without a bias. The prepass draws everything
a little farther (constant -1, slope -1), so a surface lying up to a pixel's
worth of the slope behind the front one passed as well, and the one drawn
last covered the other. Seen from the side a few metres away that is more
than a millimetre: the warning stickers 1 mm off the buffer beam of the EP07
(303e) vanished under the beam, drawn after them.

Those draws now test their depth with the bias of the prepass, nearer by two
units and 1/16 of the slope (the position is invariant in both programs).
The colour pass sets its bias in apply_draw_state() for the kept draws and
the decals together; the depth drawn inside the colour pass holds its own.

The OpenGL 4.6 renderer writes the depth in its colour pass and isn't
affected. No asset changes.
build-fix-vulkan-kept-depth-decals
2026-11-30 20:09:18 +01:00
Hirek 4c30fe4c3b Merge pull request #569 from MaSzyna-EU07/fix/snow-layer-driver-crash
Fix/snow layer driver crash
2026-11-30 19:04:16 +00:00
Hirek 3629f5051d Merge pull request #567 from MaSzyna-EU07/fix/freespot-far-cull
fix(render): the lamps of small scenery models are seen from afar
2026-11-30 19:04:05 +00:00
Hirek 01893ded61 Merge pull request #547 from MaSzyna-EU07/feat/derailment-event
A derailment is told to the scenery and ends a test run on request
2026-11-30 18:59:42 +00:00
Hirek 40a39ad390 Merge branch 'staging' of https://github.com/MaSzyna-EU07/maszyna into fix/snow-layer-driver-crash build-fix-snow-layer-driver-crash 2026-11-30 19:40:15 +01:00
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
Hirek 1562d134ff Merge pull request #564 from MaSzyna-EU07/feat/ktx2-textures
Textures: read KTX2 files (BC1-BC7, RGBA8, zstd) in both renderers
2026-11-30 17:49:53 +00:00
Hirek 269591fc35 fix(render): the lamps of small scenery models are seen from afar build-fix-freespot-far-cull 2026-11-30 18:48:43 +01:00
Hirek af7744abda Merge pull request #565 from MaSzyna-EU07/fix/e3d-export-null-matrix
fix(e3d): the -e3d export no longer crashes on a submodel without a matrix
2026-11-30 14:44:35 +00:00
Hirek 0426a44f71 fix(e3d): the -e3d export no longer crashes on a submodel without a matrix
A submodel whose definition breaks off before its transform (no "type:"
in its header) is still attached to the tree, without a matrix, and
TSubModel::serialize dereferenced that matrix. It is written as -1 now,
which the binary loader reads back as no matrix, so the .e3d holds the
same tree the .t3d gives.

The -e3d mode also runs the log service now. Without it nothing logged
during the conversion came out, neither the included files the
conversion scripts read from the standard output nor the error that
names the broken submodel. A model that loaded nothing ends with exit
code 1 and a message instead of a crash.
build-fix-e3d-export-null-matrix
2026-11-30 15:42:51 +01:00
Hirek 7d3ccd6dc4 Textures: read KTX2 files (BC1-BC7, RGBA8, zstd) in both renderers
The game now reads .ktx2 texture files, for the OpenGL 4.6 and the Vulkan
renderer alike (texture_source::load_KTX2(), parser in model/ktx2.*):

- formats: BC1 (RGB and RGBA), BC2, BC3, BC4, BC5 (unsigned and signed),
  BC6H (unsigned and signed float), BC7, and plain R8G8B8A8 / B8G8R8A8;
- the levels stored as they are or packed with zstd (the bundled zstd);
  with gfx.textures.streaming the worker threads read and unpack them;
- the KTXorientation key is honoured: "rd" files are flipped to the bottom
  row first, BC1-BC5 block by block, plain texels row by row. BC6H and BC7
  can't be flipped without decoding: an "rd" file of these is loaded as
  stored, with a warning in the log, as the BC7 dds files are. A file
  without the key is taken the way the dds files are (ddsupperorigin);
- srgb or linear colour is chosen by the material, as for the dds files;
- the alpha of BC7 is checked on a small level, as for the dds files.

Not supported, refused with the reason in the log: Basis Universal
(ETC1S / UASTC, BasisLZ), zlib supercompression, arrays, cube maps and
3d images.

BC1 without alpha, BC4, BC5 and BC6H are new formats for the renderers:
opengl_texture::mapping and the Vulkan texture_format_of() map them (no
srgb variants for BC4/BC5/BC6H; their alpha reads 1).

.ktx2 is looked for right after .dds (textures, materials, the editor's
texture browsers). Existing data holds no .ktx2 files, so nothing changes
for existing sceneries and vehicles, and no asset change in the SVN is
needed.

Unit tests: tests/unit/test_ktx2.cpp (header, levels, zstd, orientation,
refused files, flipping of BC1-BC5 and plain texels).
build-feat-ktx2-textures
2026-11-30 15:08:45 +01:00
maj00r 6a716b6720 Merge pull request #533 from MaSzyna-EU07/fix/wiperlist-bytesum-parse
Read the WiperList wiper mask as a number, not a character
2026-11-30 00:41:27 +01:00
jerrrrycho 6c3179029a refactor: the cause of a derailment in reason_of(), the log in log_derailment()
The nested conditional operators mapping DerailReason and the verdict of
the criteria to derailment::reason in Derail(), derail() and
derail_in_collision() go into the switch of reason_of() (S3358), and the
log of Derail() into log_derailment(); Derail() returns early instead of
nesting its body (S3776). The behaviour stays the same for every caller.
build-feat-derailment-event
2026-11-30 00:16:38 +01:00
jerrrrycho a81d149541 feat: a memory cell of its own for the derailment of a vehicle
report_derailment() writes the memory cell at once and only queues the
events, which run later in Events.update(). A collision derails both
vehicles in one frame, so when <A>:derailed ran, __simulation.derailment
already held B. The scenery can now declare the memory cell
<vehicle>:derailed, written the same way and with the same three fields
as __simulation.derailment, for the events of that one vehicle to read.

Documented that __simulation.derailment keeps only the last derailment
of a frame; eu07_td_off_track_end_scenery_told checks the cell of the
locomotive now.
2026-11-30 00:15:50 +01:00
jerrrrycho b0f7500004 comment: the wiper mask is read into an int, not the uint8_t build-fix-wiperlist-bytesum-parse 2026-11-30 00:12:58 +01:00
jerrrrycho 61aaaa7c62 Merge staging into feat/derailment-event
# Conflicts:
#	physics/derailment.cpp
#	physics/derailment.h
#	tests/scenarios/README.md
#	tests/unit/test_derailment.cpp
2026-11-30 00:12:29 +01:00
Hirek cabd53a01c Merge pull request #382 from pwarszawski/fix/gl46-text-displays
fix(gl46): station name boards show their text
2026-11-29 17:40:25 +00:00
Hirek fe45bb5811 Merge pull request #374 from pwarszawski/fix/glare-occlusion
fix(gl46): no more glares of light points through walls
2026-11-29 17:39:59 +00:00
Hirek d21ae35899 Merge pull request #373 from pwarszawski/fix/gl46-scenery-zero-normals
fix(gl46): scenery shapes and rail ends rendered black
2026-11-29 17:37:28 +00:00
Hirek 3a9b3e5681 Merge pull request #372 from pwarszawski/fix/cluster-cull-lamp-radius
fix(gl46): the radius of a lamp isn't a part of its brightness in the cluster culling
2026-11-29 17:37:11 +00:00
Hirek a2315990ca Merge pull request #550 from miloszunio/feat/debug-perflog
feat(debug): debug.perflog writes the times of the renderer to perf.txt while the game runs
2026-11-29 17:36:21 +00:00
Hirek f964f75ece Merge pull request #544 from MaSzyna-EU07/fix/staging-case-regressions
Fix two scenario cases broken on staging: the uuid of scene nodes, the AI stop on a gradient, an off-track coupling
2026-11-29 17:35:36 +00:00
Hirek b8f31859e9 Merge pull request #546 from MaSzyna-EU07/feat/derailment-trust-limits
physics.derailment new: trust the speed limit of the track (physics.derailment.trustlimits)
2026-11-29 17:35:05 +00:00
Hirek 4d1219e225 Merge pull request #554 from MaSzyna-EU07/cleanup/mover
Create vehicle-architecture.md
2026-11-29 17:33:37 +00:00
Hirek 5d5e271edb Create vehicle-architecture.md 2026-11-29 18:32:22 +01:00
jerrrrycho ba6ad19c08 Merge staging into fix/wiperlist-bytesum-parse 2026-11-29 18:04:01 +01:00
jerrrrycho a8bd72cc7f Merge staging into fix/staging-case-regressions build-fix-staging-case-regressions 2026-11-29 18:04:00 +01:00
jerrrrycho c0e1f1c8fe Merge staging into feat/derailment-trust-limits build-feat-derailment-trust-limits 2026-11-29 18:04:00 +01:00
jerrrrycho ee2392f29f Merge staging into feat/derailment-event 2026-11-29 18:03:59 +01:00
jerrrrycho 5182e4eb43 Merge pull request #548 from MaSzyna-EU07/test/baltyk-skm1-cases-new-units
test(scenarios): baltyk_skm1 cases follow the new units of their missions
2026-11-29 17:12:04 +01:00
Hirek 48f2162b3b Merge pull request #552 from MaSzyna-EU07/cleanup/mover
(refactor/mover) stage 2: the vehicle keeps its state to itself
2026-11-29 16:03:53 +00:00
Hirek 969864f204 Merge staging into cleanup/mover
The windscreen weather (#367) and the compiler cache of the CI (#434). The
wipers' code of both renderers takes staging's side, reading the active cab and
the speed through TDynamicObject (ActiveCab(), Speed()) as the renderer does on
this branch; the windscreen water reads the speed the same way, and the deer
(world/deer.cpp) read the vehicle through its queries (V(), WarningSignal(),
CabOccupied()).

The golden traces recorded on dfb43c4f still match bit for bit: staging didn't
touch the physics.
build-cleanup-mover
2026-11-29 16:55:25 +01:00
Hirek c7c170a3cb Merge pull request #434 from MaSzyna-EU07/build/ci-compiler-cache-master
ci: shorter CI runs on pull requests
2026-11-29 15:38:41 +00:00
jerrrrycho efde2157eb fix: the derailment notice builds on the layout of #531: physics/derailment.h, TDynamicObject::physics 2026-11-29 16:04:43 +01:00
jerrrrycho de6e886048 test: the trusted-limit cases check the derailment as VehicleDamage, as staging does since #531 2026-11-29 15:24:16 +01:00
jerrrrycho 66908502b3 test: the off-track coupler case names the ends as VehicleEnd, as staging does since #531 2026-11-29 15:07:19 +01:00
jerrrrycho c1d1f1aead Merge staging into feat/derailment-event
# Conflicts:
#	McZapkie/Mover.cpp
#	vehicle/DynObj.cpp
2026-11-29 14:57:22 +01:00
jerrrrycho 1e825cb596 Merge staging into feat/derailment-trust-limits
# Conflicts:
#	McZapkie/Mover.cpp
2026-11-29 14:56:21 +01:00
jerrrrycho 501123c3b8 Merge staging into fix/staging-case-regressions
# Conflicts:
#	McZapkie/Mover.cpp
#	physics/vehicle.h
#	vehicle/Driver.cpp
#	vehicle/DynObj.cpp
2026-11-29 14:54:08 +01:00
Hirek d631837796 Merge pull request #367 from lcddisplay/feat/windscreen-weather-gl46
Windscreen weather (rain, bugs, snow), moths, deer and VAT animation for OpenGL 4.6 / Vulkan 1.4
2026-11-29 12:50:39 +00:00
Hirek f6c573340a docs(agents): the state of a vehicle changes outside the physics only through its operations
AGENTS.md says that outside physics/ the state of a physics::Vehicle changes
only through its operations, its definition aside as the vehicle loads; that a
field the rest only reads is private with a query named as the field was, one
nothing outside uses private outright, and a new one private from the start;
and that the cab and the events read the AI through its queries, the debug and
timetable panels alone being its friends.
2026-11-29 13:39:08 +01:00
Hirek 23b695752a refactor(physics): the demand of the integrated controller is private to the vehicle
eimic_real, the demand of the integrated controller the vehicle goes by with
the speed control counted, which TDynamicObject and the consist braking set
for the vehicle that leads, is private: EimicReal() and SetEimicReal(). The
field of the same name of drivingaid::input stays as it is.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 13:39:07 +01:00
Hirek f0978c36c7 refactor(physics): what nothing outside the vehicle uses is private to it
71 public fields of physics::Vehicle that no code outside the class reads or
writes (the definitions of the circuits and the tables only the vehicle's own
step goes through, the forces and the timers of its step, the programmable
controller, ...) move into its private part as they are, with the comments
above them. The fields of the old doors inside EU07_USEOLDDOORCODE stay where
they are.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 13:32:05 +01:00
Hirek ef8a1fdbfd refactor(physics): six more of what the rest only reads are private, under names of their own
The mass of the empty vehicle, the braking force, the outcome of a derailment,
the departure signal, the traction mode of a dual-mode vehicle and the moment
of the motors are private to physics::Vehicle like the 53 before them, read
through Mass(), Fb(), Derailed(), DepartureSignal(), TractionMode() and Mm().
Inside the class they are emptyMass, brakingForce, derailOutcome,
departureSignalOn, tractionModeSetting and motorMoment, as the plain camelCase
names were taken by locals there.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 13:23:53 +01:00
Hirek 5879c228dc refactor(physics): what the rest of the simulator only reads of a vehicle is private to it
53 fields of physics::Vehicle that only the vehicle itself writes, and the rest
of the simulator reads, are private, with a query each, named as the field was
(Vmax(), TotalMass(), Ft(), nrot(), NAxles(), PhysicActivation(), ...): the
compiler now keeps the cab, the AI, the scenery, the renderer and the tests from
changing what the definition gives or the physics works out. The fields were
picked by what is never written outside the class, of plain types, with no
other member of the same name to confuse; inside the class they keep their
meaning under camelCase names. The one place outside that cleared a flag of
the AI through a reference does it through ClearAIFlag().

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 13:17:56 +01:00
Hirek 74f0aa240d refactor(ai): the cab and the whois event are no longer friends of the AI, its public fields are private
TTrain and whois_event reached into the private members of TController as its
friends; they read what the AI knows of its consist and its route through
queries now (ConsistDoorsOpen(), ConsistConverterOverloaded(), ConsistLength(),
DesiredVelocity(), NextSignalVelocity(), BrakesReleaseLevel(), ...), and the cab
changes the radio channel through SetRadioChannel() rather than a reference to
the AI's field. The reversers of the consist, the stations of the timetable and
the obstacle ahead are public queries and operations.

The public fields of TController are private: whether the AI drives
(AIControllFlag()), the masks of the running without current the vehicles of
the consist set (MarkOverhead(), the same bits TDynamicObject::OverheadTrack()
set itself), the most deceleration of the blended brakes (MedAmax(),
SetMedAmax()), and the positions the driving aid panels show. Only the four
debug and timetable panels stay friends.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 13:06:16 +01:00
Claude 231bd3eb84 Bugs: the big and the huge ones smaller (2.5x and 5x the normal ones, were 4x and 9x)
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