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

58 Commits

Author SHA1 Message Date
maj00r 49ef69bb34 Merge the review fixes of the PRs below from feat/eu07m-clips into feat/eu07m-skin-compute 2026-11-29 18:22:14 +01:00
maj00r 05a8ddaabd Merge the review fixes of the PRs below from feat/eu07m-instancing into feat/eu07m-skinning 2026-11-29 18:22:12 +01:00
maj00r f2859b11ae Merge the review fixes of the PRs below from feat/e4d-compact into feat/eu07m-instancing 2026-11-29 18:22:11 +01:00
maj00r 3b9d8b2fa3 fix(render): EU07M review of #537: no whole vertices kept for the bounds, the compact variant checked by CI and given up when it fails
- The bounding radius, offset() and MaxY() read the positions of a chunk alone (Positions(), geometry_bank::positions()):
  on Vulkan the compact streams are no longer decoded into basic_vertex and kept for the life of the bank as every model
  loads, so the host memory of EU07M models stays below that of E3D. What still needs whole vertices (the editor, the
  picking, the export) decodes them on first use as before.
- A COMPACT_VERTEX variant which doesn't compile is told once in the log and the banks of EU07M models go back to
  basic_vertex (compact_layout_failed()), those built already when they are drawn next, instead of the models being left
  out for the session.
- The shader validator compiles the vk14 shaders which have COMPACT_VERTEX with it, alone and with MODEL_DRAWS, as the
  renderer makes the variants.
2026-11-29 18:12:50 +01:00
maj00r 6c7ec65825 feat(render): the skinned parts of EU07M models moved by a compute shader in Vulkan
The skinning of stage 4 moved the vertices on the CPU and replaced the geometry of each instance. The Vulkan renderer moves
them in a compute shader now; GL 4.6 stays on the CPU.

- gfx::skin_cache: the walks only work out the palette of the joints; flush(), before the walks of the next frame, moves
  the vertices of the instances whose pose changed: through the new GfxRenderer->Skin_Geometry() where the renderer can,
  else on the CPU with Replace / Replace_Indexed as before. A chunk made or emptied makes the buffers of the bank anew from
  the vertices the CPU holds, so every instance skinned on the GPU is moved again then.
- Vulkan (rendering/vulkan14/vulkan14skinning.cpp, shaders/vk14/skin.comp): the bind pose with the weights of a skinned
  part goes to the GPU once, the palette in the ring of the frame; the kernel writes the moved vertices over those of the
  chunk of the instance in the buffer of its bank (gfx::basic_vertex), with barriers against the copies of the uploads and
  the draws of the frames before, and before the draws of the frame. The vertex buffers of the plain banks get the
  storage usage. The kernel is made the first time a part is skinned; without it the CPU moves them.
- eu07.ini: gfx.skinning.gpu (default yes); no moves them on the CPU in Vulkan too. Both give the same picture.

Checked in Vulkan: a tube of two joints turned by 60 degrees, GPU against CPU, with gfx.gpucull 0 and 1: no pixel
differs, and the log shows the kernel ran. Two instances, the second posed later: the first keeps its pose through the
rebuild of the bank, the same as on the CPU. A clip moving the tube every frame. GL 4.6 after the change of the cache:
both instances bent as before (time let run in the editor for the tests only). Unit tests 1200/1200. Not measured on a
large scene, not built with GCC here.
2026-11-29 01:17:01 +01:00
maj00r d324c53233 feat(model): skinned parts of EU07M models move with their joints, skinned on the CPU
Stage 4 of the EU07M model format. A primitive with a skin (SKIN, SKJT, weights in VSKN or VSKW) was drawn in its bind
pose. Now it follows the joints of its skin, in both renderers.

- The joints are nodes of the model, so they're posed as before: animation events, the .mmd, SetRotate / SetTranslate
  from the vehicle code. The matrix of a joint is world(joint) * inverse bind(joint), world being the transform of the
  joint from the root of the model with the animations of the instance drawn (TSubModel::posed_transform()); the
  vertices lie in the bind pose in the space of the model, the transform of the node of the mesh left out, as in glTF.
- The loader keeps the bind pose and the weights of a skinned primitive (skinning::skinned_geometry on the submodel) and
  the skins of the model (TModel3d::skins()).
- The first pass of a frame to draw a skinned submodel of an instance works out the palette and, when it changed, moves
  the vertices on the CPU: positions by the blended matrix, normals and tangents by its rotation (model/skinning.cpp,
  gfx::skin_cache in rendering/common/skincache.cpp). The geometry of the instance is made or replaced before the passes
  of the next frame (flush() in the frame setup of both renderers), as nothing the passes draw may change while they draw
  (gfx::walk_sync): the vertices follow the joints a frame late. In the bind pose the shared geometry of the model is
  drawn; an instance not drawn for 600 frames lets go of its own.
- Fix: a node with range_max_sq 0, which the spec gives as no limit, was never drawn (a model made anew rather than
  converted from E3D); it keeps the default range of a submodel now.
- The editor self-test gets "animate <node> <submodel> <x> <y> <z>", which turns a submodel of an instance as an
  animation event does, since the editor doesn't run the events.

Not in this commit: the skinning in a compute shader, bounds of the posed submodel, motion vectors and ray tracing of the
moved vertices.

Checked: a tube of two joints in two instances, one turned by 60 degrees at its middle, bends smoothly while the other
stays straight, in Vulkan and GL 4.6, with gfx.gpucull 0 and 1 (time let run in the editor for the test only). Unit
tests 1194/1194, 5 new ones for the weights, the bind pose, the blending and the file. Not built with GCC here.
2026-11-28 23:52:35 +01:00
maj00r 8a82433a11 feat(render): models with lights drawn instanced, behind gfx.instancedlights in eu07.ini
Stage 5 of the EU07M model format. A model with lights (lights, Light_On## / Light_Off##), such as a signal head, was
drawn instance by instance, a draw call for each part of each one. With gfx.instancedlights 1 the instances of such a
model go into the instanced batches like the others, in both renderers, with the culling of the GPU and without it. The
default 0 draws them as before. It applies to EU07M and E3D models alike.

- The light state of an instance is a word in the element [0][3] of its instance matrix, which an affine matrix leaves
  unused: bits 0-7 the lit parts shown, bits 8-15 the dark parts, in the mantissa of a float of exponent 128
  (0x40000000), a normal number the GPU carries through its matrix products whole. Without that marker the shader
  draws everything, as before.
- model_ubs.light_part says which part of which slot a draw is (0 none, 1 + slot lit, 9 + slot dark); a part the
  instance doesn't show gets a zero matrix in the vertex shader (instance_hides_part() and effective_modelview() in
  shaders/vk14/common.glsl and shaders/ogl46/common.glsl). The batch instance shows every light part
  (TAnimModel::RaPrepareInstanced()).
- CPU path: each instance drawn is animated (RaAnimate) and its word put in its matrix (Render_Instanced). GPU culling:
  the word is in rotationscale[0].w of the instance record, refreshed once a frame for buckets with lights
  (Refresh_Light_Records), which marks the records to send again when a word changes.
- An instance shows the whole lit part or the whole dark one: blinking and switching (ls_On / ls_Off / ls_Blink) change
  over at half the fade, where the draw instance by instance fades the lit part in over the dark one. Steady states look
  the same as before.
- The freespot lights (TP_FREESPOTLIGHT with flag 0x4000 and no animation) don't keep a model out of the instancing
  when gfx.instancedlights is on. Light parts aren't put in the ray tracing of an instance batch.

Measured on Vulkan, 200 heads s4ipcpb_dd: with gfx.gpucull 0 frame 9.2 ms -> 1.5-2.5 ms and 2400 -> 16 draw calls, with
gfx.gpucull 1 9.1 ms -> 3.0 ms and 2410 -> 26 draw calls. Steady light states pixel for pixel the same as drawn
instance by instance on all three paths in Vulkan, and on GL 4.6 where the editor panels don't cover them; blinking
checked in Vulkan on all three paths (with time let run in the editor for the test only). Not run in the driver mode,
blinking not checked on GL 4.6, not built with GCC here. Unit tests 1189/1189.
2026-11-28 23:10:53 +01:00
maj00r 92cc2dcc28 refactor(model): the new model format is EU07M (.eu07m), not E4D
E4D read as the next version of E3D, which the format isn't meant to be tied to; EU07M goes with the world format .eu07.
The format isn't released, so nothing reads the old name.

- The extension .eu07m, the magic EU7M (the four bytes of the header), model/eu07m/ with eu07m_*.{h,cpp},
  namespace eu07m, docs/eu07m-format.md, tests/unit/test_eu07m.cpp.
- The command line -eu07m convert|dump|validate|diff, TModel3d::LoadFromEU07M, and the key modelformat eu07m|legacy
  of eu07.ini (Global.modelformat_eu07m).
- Nothing else changes: the sections, the records and the components are the same, so a converted file needs only its
  magic and its extension changed.

Unit tests 1189/1189.
2026-11-28 22:02:05 +01:00
maj00r 5185d69dc9 feat(render): the Vulkan renderer keeps the vertex streams of E4D models as they are, 28 bytes a vertex
Stage 3 of the E4D model format. A model loaded from .e4d (modelformat e4d) reaches the Vulkan renderer as its compact
streams: positions (12 B), attributes (QTangent snorm16x4 + uv f32x2, 16 B), user data and indices, without the 48-byte
gfx::basic_vertex in between.

- gfx: gfx::compact_attributes, geometry_bank::create_compact() and GfxRenderer->Insert_Compact(). The default of
  Insert_Compact decodes to basic_vertex, so the OpenGL 4.6 and the null renderers get the models as before. The CPU
  readers of a chunk (pantograph, bounds, picking, the editor) get basic_vertex made from the streams the first time they
  read it; a chunk which is changed (replace, append) turns into basic_vertex first.
- Vulkan: a bank whose chunks are all compact keeps positions, user data, attributes and indices in buffers of their own;
  vertex_kind::scene_compact reads them (location 5 the quaternion as R16G16B16A16_SNORM). A program gets a COMPACT_VERTEX
  variant the first time a compact chunk is drawn with it, in the background with gfx.vulkan.asyncresources, as the
  MODEL_DRAWS one; the variant of the multi draws makes a compact one of its own. Only vertex.vert and cabprobe.vert
  decode the normal (compact_frame() in common.glsl); the shaders of shadows, prepass, picking and cube shadows read
  position and uv as before.
- Ray tracing: the BLAS of a compact chunk reads the positions with a stride of 12, and the reflections read the normal
  and uv from the attributes (RT_FLAG_COMPACT in the record). Not tried with ray tracing on.
- The loader hands the streams of the file to Insert_Compact as they are; the stars keep their colours in the normals
  of basic_vertex and go as before.

Measured on Vulkan (self-test, 250 models of the game, runs alternating with legacy): device memory 1.60-1.64 GiB
against 1.89 GiB, GPU time a frame 1.27-1.39 ms against 1.37-1.57 ms, the same frame time and load time, the picture
within 1/255 of the legacy one, no errors of Vulkan in the log. Unit tests 1189/1189; -e4d diff gives the same results
through the new decode. Not built with GCC here.
2026-11-28 21:52:47 +01:00
jerrrrycho 702b552780 fix(render): particle vertex attribute offsets from offsetof in the GL 4.6 and Vulkan renderers (#511)
* fix(render): particle vertex attribute offsets from offsetof

* fix(render): particle vertex attribute offsets from offsetof in the GL 4.6 and Vulkan renderers

The GL 4.6 particles passed 0, 12 and 28 to setup_attrib, the Vulkan layout of
vertex_kind::particle had the stride 36 and the same offsets as numbers. They
now come from sizeof and offsetof of particle_vertex. The Vulkan particle_vertex
moves from vulkan14frame.cpp to vulkan14context.h so the layout in
vulkan14scene.cpp can use it.

A build with static_asserts that each offsetof equals the old number (and the
size 36) compiled; the asserts were taken out after.
2026-11-27 23:51:25 +01:00
Hirek 0ce190eab2 fix: the review of the renderers PR: physics switches off by default, crashes on exit and at start, renderer, shader and editor fixes 2026-11-27 09:15:11 +01:00
Hirek 7e26e79297 feat(render): the pbr materials of the metallic and roughness workflow (pbr, pbr_detail, pbr_parallax, pbr_coat) 2026-11-26 00:31:35 +01:00
Hirek ad71963a4e fix(render): the Vulkan renderer checks its cache files, backs off when memory runs out and keeps its threads alive through any exception 2026-11-25 15:29:31 +01:00
Hirek b0ebd83475 Merge branch 'feat/gl46-migration' of https://github.com/MaSzyna-EU07/maszyna into feat/renderers-cleanup 2026-11-25 15:29:12 +01:00
Hirek 43c46952ab perf(render): the Vulkan renderer resolves MSAA once a pass, keeps the window of the draw blocks and makes the multi draw shaders and ray tracing textures in the background 2026-11-25 10:27:31 +01:00
Hirek e0f07fde71 fix(render): the Vulkan renderer doesn't hang on exit, draw a minimized window with a NaN projection or quit on a lost surface 2026-11-25 09:34:58 +01:00
pol102 4ba8d508ca fix(gl46, vk14): keep the loading screen up while the shaders and pipelines are prepared, instead of a black window (#476)
* fix(gl46): the loading screen stays until the shaders are compiled, no black window at the first start of a new version

At the first start of a new build (the driver keeps the compiled shaders of each executable apart, and every build has a name of
its own) the window went black and didn't answer for about half a minute after the scenery was loaded. Measured on
calkowo_osobowy with a copy of the executable under a new name: 33 of those seconds were the first step of the water on the
windscreens, which compiled its nine programs (water_*.comp) in the first frame of the simulation.

- After the scenery is loaded the loader keeps its screen, with the bar going and the note on preparing the graphics, until the
  renderer says the programs are ready (gfx_renderer::Prewarm_Shaders(), about 50 ms a frame): the programs of the materials
  are drawn with once each into a small target of the formats of the colour pass, as the opaque things and as the translucent
  ones, then the programs of the windscreen water are compiled one a frame (opengl46_windscreen_water::prepare_next()), which
  gpu_init() then keeps. The window answers in between.
- The Vulkan renderer, which has its pipeline cache, says it's all done at once (the default of the interface).

Checked with a copy of the executable under a new name (nothing kept by the driver): the loading screen with the note from the
end of the loading (19 s) to the first frame (58 s), the window answering all the time; the first frame no longer stalls (the
water 12 ms instead of 33 s). With the shaders kept by the driver the preparing takes no time.

No asset changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(gl46): the missing program of the windscreen water found by find_if, which GCC 13 and MSVC 14.4x compile

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(loading): the notice that the graphics are being prepared at the top of the screen

The notice stood at the bottom left, beside where the loading icon goes, over the trivia and the texts some
of the backgrounds carry at the bottom. It is now centred at the top of the screen on a dark plate, so it
reads on any background. The text and its translation are the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(vk14): the loading screen stays until the pipelines of the scene are made, as with OpenGL 4.6

vulkan14_renderer::Prewarm_Shaders() lists the pipelines the loaded scenery draws with most: those of the
programs of its materials for the colour pass of the main view, opaque and blended, and those of the
shadows. With the background threads (gfx.vulkan.asyncresources) they are handed to them, made ahead and
not counted as made late; without them they are made on the main thread for about 50 ms a frame. The
loading screen, with its notice and progress bar, waits for them and for the pipelines of the last
session the background threads make ahead. Before, a pipeline first asked for by a draw either left the
draw out for a few frames or held the frame while it was made.

The images of a viewport are made by make_viewport_targets(), taken out of render_scene() unchanged, so
the main view's formats are known before the first frame. The key and the settings of a pipeline come
from the same helpers bind_scene_pipeline() uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(gl46, vk14): the review of #476: the multi draw variants prewarmed with a model block, the last session's list in the progress

OpenGL 4.6: with gfx.gpucull 1 and the multi draws on, Prewarm_Shaders() also draws the multi draw variants
of the material programs. Their shaders read the model block from the storage buffer at
MODEL_DRAW_SSBO_BINDING, which nothing bound before the first frame, so the draw was undefined. The
prewarm now binds a buffer of one model block there. With the default gfx.gpucull 0 there are no such
variants and nothing changes.

Vulkan: the loading screen waits for the background threads, and so for the list of the last session, up
to 4096 pipelines. With a cold cache the bar stood at n/(n+1) all that time and looked stuck. The
pipelines of that list are now counted in the progress as they are done with, made or not. The wait still
ends when the background threads are idle, as before.

make_viewport_targets() returns false without a context, which Sonar reported as a null pointer
dereference. Its callers checked the context already.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QRgQ1LqB4YXWorLDBBL6hD

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 05:14:33 +01:00
Hirek 51c76da927 fix(render): the free camera blurs with its own movement in the OpenGL 4.6 and Vulkan renderers 2026-11-23 20:55:50 +01:00
Hirek b91f1f5747 Reduce clouds noise 2026-11-17 01:38:17 +01:00
Hirek 91c2d3aba9 Clouds and fog tweaks 2026-11-17 01:02:52 +01:00
Hirek 9071d3f4d3 Improved water shader 2026-11-16 22:55:33 +01:00
Hirek b8815a2455 Optimise raytracing and buffer building 2026-11-16 22:19:17 +01:00
Hirek 053e4cacee Merge branch 'master' into feat/renderers-cleanup 2026-11-16 21:44:48 +01:00
Hirek 9d20c9ac61 fixes 2026-11-10 17:09:19 +01:00
Hirek ff2ff308ed Some optimalisations 2026-11-09 20:58:02 +01:00
Hirek 7667e5b2ec fix: the bugs and vulnerabilities SonarCloud reports on PR #216 2026-11-07 22:11:08 +01:00
Hirek acbea51f81 fix: the build after the merge of master 2026-11-07 16:46:11 +01:00
Hirek 75cb88f275 Map BC7 (BPTC) dds textures to native VK_FORMAT_BC7 in the Vulkan renderer 2026-10-31 16:46:35 +01:00
Hirek 7078edf138 fix(vulkan): read back the editor cursor depth and correct the depth pass bias 2026-10-30 01:33:41 +01:00
Hirek 765153ad91 Merge remote-tracking branch 'origin/feat/switch-blades' into feat/renderers-cleanup 2026-10-29 23:55:04 +01:00
Hirek 96100f1155 Draw the cab probe with all the lights of the cab 2026-10-29 20:05:03 +01:00
Hirek 8bd41f431d Keep the slices of the ring caches within the window the shaders index from 2026-10-29 19:21:14 +01:00
Hirek 975fc1b4ea Look 4 GiB lower for the buffer of a fault address that holds nothing 2026-10-29 19:15:44 +01:00
Hirek bcf2c14b20 Place the images of the allocator blocks in the device-lost report exactly 2026-10-29 18:57:53 +01:00
Hirek 325be54b2c Name the buffer or image a Vulkan device fault hit in the device-lost report 2026-10-29 18:04:38 +01:00
Hirek 9904eddd0d Light the cab with cablight/dashboardlight light points of the cab model 2026-10-28 20:55:45 +01:00
Hirek 8f891fdc14 Report where the GPU got to when the Vulkan device is lost 2026-10-28 20:21:00 +01:00
Hirek c4e23932bf Add the optional Radius, ShadeSelf, CastShadows and SoftFalloff of FreeSpotLight and make FalloffAngle 360 a point light 2026-10-28 16:18:03 +01:00
Hirek e8a90507f0 Light the cab with the sun coming in through its windows 2026-10-28 12:19:43 +01:00
Hirek 1447dcf075 Walk the shadow passes and the culled model groups on worker threads in the Vulkan renderer 2026-10-27 20:56:11 +01:00
Hirek c44b243698 Shade the sky and the sun by the scenery around the camera instead of the track environment flags 2026-10-27 17:11:06 +01:00
Hirek 2a876befb0 Shade the sky and the sun by the scenery around the camera instead of the track environment flags 2026-10-27 16:02:36 +01:00
Hirek 9dde5b0e5e Take the ambient occlusion into the lighting and add a probe of the cab 2026-10-27 13:23:52 +01:00
Hirek ac0b4e5f15 Add a white balance to the tonemapping 2026-10-27 01:40:19 +01:00
Hirek 719c729929 Improve rain shader 2026-10-26 15:51:56 +01:00
Hirek a6bdeeaa2b Add DLSS Frame Generation (gfx.framegeneration x2/x3/x4) and Reflex (gfx.reflex) to the Vulkan renderer 2026-10-25 20:52:12 +01:00
Hirek 1841e6d7b0 Add NVIDIA DLSS to the Vulkan renderer (gfx.antialiasing dlss/dlaa) and gfx.buffer.percent 2026-10-25 19:35:33 +01:00
Hirek 71a6628a4a Vulkan ray tracing: shade the heightmap terrain from its layers; longer default SSR range 2026-10-25 17:15:58 +01:00
Hirek e201c83825 Vulkan ray tracing: trace only visible reflections, sun shadow from the shadow map, foliage switch and timings 2026-10-25 16:09:19 +01:00
Hirek 08f4f6ed60 Vulkan ray tracing: include tracks and roads, build triangle strips and fans 2026-10-25 15:35:26 +01:00