23 Commits
Author SHA1 Message Date
Thomas MartinandClaude Opus 5.5 e590551574 render: setBackdrop shows a part of its texture (the picture in a power-of-two one)
A movie picture decoded as a texture is rounded up to powers of two: a
640 x 448 picture in a 1024 x 512 texture. setBackdrop mapped the whole
texture to its rectangle, so a port had to draw it larger than the
picture and let the window cut the padding off. Where the window does not
(a 4:3 picture kept 4:3 in a widescreen frame, or a letterbox), the
padding showed: Amplitude's widescreen movies had a strip of stale
pictures at the right and below.

Two trailing parameters (u, v) give the part that is the picture; their
defaults (1, 1) keep every port's call as it was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-27 12:46:56 +01:00
Thomas MartinandClaude Opus 5.5 2903dbe686 Renderer: draws assembled in place (appendVertices, drawRange, continueFrame)
A port that makes its draws' vertices itself (Shinobido's GS translator: 30,000
primitives a frame) built them in its own batches and draw() copied every one into the
frame being built at the flip. Now it can make them straight into that frame:
appendVertices gives room at its end, drawRange adds a batch over vertices already there
(two batches may share a range, as a two-pass draw's do), and continueFrame starts the
frame like beginFrame but keeps the vertices appended since the last one ended. draw() is
append + drawRange (a refused batch keeps none of its vertices).

tests/render/draw_in_place_tests.cpp: the same frame digest as draw()'s copies, shared
ranges, a range past the vertices refused, beginFrame dropping what was appended.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 13:38:17 +01:00
Thomas MartinandClaude Opus 5.5 8ee365b4a2 Material depth offset: decals land under anti-aliasing
Material::depthOffsetSlope / depthOffsetUnits (glPolygonOffset, toward the camera): with anti-aliasing a
target sharing the frame's depth gets the depth resolved from one sample point off each pixel's centre,
which on a steep surface can lie nearer than a decal's centre depth, so marks laid at the surface's own
depth all failed (Dark Cloud's character shadows vanished at 4x). 0, 0 (the default) draws as before.

native_render_targets: a decal on a steep slope through a shared-depth target lands with no
anti-aliasing (with and without the offset) and, with the offset, at 4x and 8x. Without the offset at
4x every mark failed (checked, not kept as a case: which sample the resolve takes is the driver's).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 10:50:23 +01:00
Thomas MartinandClaude Opus 5.5 4cdc9660d6 Material::depthFromTexture: a GS Z buffer image written as depth
A draw whose texture holds a 24-bit GS Z per texel (R, G, B its low,
middle and high bytes) writes that Z as its depth, through a small
program of its own (the main one keeps its early depth test), on the
vertex shader's mapping (window depth 1 - Z / depthMax). A port loads a
pre-rendered scene's depth this way before its 3D: Onimusha's rooms
upload their cut's Z buffer (PSMZ24) each frame for the models' ZTST.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-23 17:37:12 +01:00
Thomas MartinandClaude Opus 5.5 bbdef874c7 Line batches: draw a frame batch as GL_LINES segments
Material::lines makes a frame draw's vertices segment pairs (the GS's
LINE / LINE STRIP, one pixel wide) instead of triangles. An odd count,
image processing or an overlay batch rejects; the flag is hashed only when
set. VP2S: the forest minimap's outlines. An admission/digest check and a
GPU row check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 21:56:29 +01:00
boubou666 9c086590e0 Merge pull request #108 from TheBozos/vp2s/depth-colour-lookup
Depth colours: an RGBA table for the native depth lookup
2026-11-19 20:20:43 +01:00
Thomas MartinandClaude Opus 5.5 f4a5cdf96d Depth colours: an RGBA table for the native depth lookup
ImageProcessing::depthColours reads depthWeights as 64 RGBA entries (alpha
1.0 = the GS's 0x80), the index clamped to 63, replacing the texel. With
Blend::DestinationBySource this is a port's depth fog: a ramp colour added
and the scene scaled by the ramp's alpha (VP2S: the Lost Forest haze).
Hashed only when set, so existing frame digests are unchanged. Two
admission guards, a digest check and a GPU case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 20:15:49 +01:00
Thomas MartinandClaude Opus 5.5 ead0535d31 Window: hidden test runs and offscreen captures; z-fail stencil counting
- WindowOptions::hidden (never shown) and captureScene (also PS2X_CAPTURE_SCENE=1): the window presents
  into an offscreen picture, captures read it, then it is copied to the window. A hidden or covered
  window's back buffer read back black, so captures depended on what was on top of the desktop.
- Renderer::present returns to the framebuffer it was called with instead of 0.
- gl: BlitFramebuffer.
- Material::stencilDepthFail: stencilOp counts where the depth test fails (z-fail), for closed volumes
  the near plane cuts or the camera is in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 22:56:22 +01:00
Thomas Martin 91b1e17aba Merge remote-tracking branch 'origin/main' into codex/vp2s-glow-lerp-chain
# Conflicts:
#	tests/render/image_processing_gpu_tests.cpp
2026-11-18 01:37:45 +01:00
Thomas MartinandClaude Opus 5.5 0273728b74 Draw a game's GS lerp-chain blur exactly (ImageProcessing::chainTaps)
A blur drawn as GS sprites (a base copy, then lerps C = floor((S - C) * a / 128) + C at
1/16-texel offsets) truncates at every step in 8-bit integers, so no linear kernel gives the
same image: for VP2's glow the float kernel was about twice as bright as the game's. The
chain mode does the same integer steps in the shader: base texel modulated by chainColour,
each tap bilinear with 4-bit weights, edges clamped, modulated, floored, lerped.

Tests: the GPU result equals a CPU reference of the same steps; four new admission guards.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 01:02:31 +01:00
Thomas MartinandClaude Opus 5.5 e6ed3cff03 Draw an auxiliary image with the main frame's depth (Material::frameDepth)
A per-draw flag: the draw's auxiliary target tests and writes the main frame's
depth buffer instead of its own, as a GS draw into another frame address with
the same ZBUF would. VP2S's multi-copy depth blur needs it to compare depth
planes with the scene into a marker image without touching the frame's alpha,
which here is the presentation's coverage. The global shared-depth bits are
read when the frame executes, so they cannot be toggled around one draw.

The image takes the main frame's dimensions; a frame-depth draw without an
auxiliary target is rejected. The draw digest includes the flag only when set.
The GPU image test covers a plane between two scene depths, an unchanged main
depth (no write), and a later ordinary draw that has its own depth again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-11 18:11:21 +01:00
Thomas Martin 3ae3902d23 Preserve native colour interpolation and atlas sampling
Interpolate vertex colour in screen space while retaining perspective texture coordinates. Add opt-in display RGB and fragment atlas bounds, include active material extensions in draw digests, and cover varying-depth colour interpolation with GPU readback.
2026-11-08 17:33:13 +01:00
Thomas Martin 27b8672f54 Add native image kernels, depth lookup and opacity images 2026-11-08 16:51:49 +01:00
Thomas Martin 7e1aaad72c Add ordered native colour-level correction to frame materials 2026-11-07 17:40:40 +01:00
ArzarothandClaude Opus 5.5 54dc885b3b [sc3/render-mipmaps] feat(render): mip levels on Material and Texture, off by default
Material::mipmap (levels, filter within and between levels, LOD from the
screen footprint, from the GS's Q with K and L, or fixed) and mipmapOf(tex1)
for the GS's TEX1. Texture::levels carries a port's own levels; without them
the renderer makes the chain from level 0 at upload. levels 0 samples level 0
as before; the draw digest folds the mipmap and a texture's levels only when
set, so existing references keep their hashes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 09:21:51 +01:00
ArzarothandClaude Opus 5.5 f0c214bc5c [sc3/render-tfx] feat(render): Material's texture function and texture alpha (TEX0.TFX, TCC)
Default Modulate with the texel's alpha, as before; the digest folds them only when set, so references keep their hashes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 02:38:46 +01:00
ArzarothandClaude Opus 5.5 165e0b6137 [sc3/render-stencil] feat(render): Material's stencil: counting by a volume's fragments, drawing where the count is not 0
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 00:36:35 +01:00
ArzarothandClaude Opus 5.5 0bcc3e08b6 [sc3/render-gs-terms] feat(render): Material::useQ, gsBlend, colourMask, alphaFunc and depthGreater (a port's GS draws drawn as the GS draws them)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 00:16:38 +01:00
Thomas Martin 11cb6df323 Add reusable native image, compiled-library and port services 2026-11-06 02:47:13 +01:00
Thomas MartinandClaude Opus 5.5 171389f470 Renderer: published frames are recycled (their vectors' capacity kept); the draw-list digest only when a record wants it
Each game frame was built in fresh vectors (the previous frame's moved into the published one): a busy frame's
vertices, several MB, grew by doubling and touched new pages every frame, and were freed by whichever thread let go
last (Renderer::draw was 2.8% of the game thread, against the fork's 0.2%). Frames now come back to a small pool when
their last holder lets go. noteDrawList hashed every vertex of every frame for the record's `draws` field: the free
host turns it off when it writes no record (Renderer::setDrawDigest); the call-log checks keep it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 23:15:23 +01:00
Thomas MartinandClaude Opus 5.5 2ed83b7ff0 Phase 4 M4b: frames between the game's (the fork renderer's interpolation moved: the smoothed clock and history at publishing, pickInterpolated, matchFrames, keyed matrices and tracked triangles between two frames) wired to video.ini's frame_rate, the Video tab and the window's loop (vsync at the monitor's rate, or n a second); FramePacer's step on its own schedule (a wake-up's overshoot was counted twice: the EE clock ran 1 % fast and the sound was dropped every few seconds)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 16:23:01 +01:00
Thomas MartinandClaude Opus 5.5 fa08bec901 Phase 4 M1: the renderer's present side on OpenGL 3.3 core (render/present_gl.cpp: the fork's GPU half moved off raylib's rlgl, its 330 shaders kept; gl.h, our own table of the 70 GL functions loaded at run time), the depth tiles read one present late, sampleTarget's target copy; bozo_app (BOZO_APP, SDL3 3.4.20 static): the window and present loop, the keyboard and gamepad as port 1, PNG captures; the free host in real time (realTime, requestStop); FramePacer keeps the cap's schedule (60.0 frames a second, not 59.4)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 12:52:40 +01:00
Thomas MartinandClaude Opus 5.5 60a8d50e1f Phase 4 M0: a port's overrides run natively (bozo/port.h), the free host, the renderer's game side and the packs moved
TMB_Recomp's runtime builds on BozoEngine (its branch bozo/m0, cmake -DTMB_BOZO=ON): its overrides run natively, each
call checked against the reference's log (tmb-check), and with no log at all (tmb-headless).

- Port API (runtime/include/bozo/port.h, bozo_port): Registry::registerFunction, BOZO_PORT, the startup check that
  every registered override is an external of the generated code (port::undeclared), and what overrides use: the
  kernel (changePriority, rotateReadyQueue, transfer), the EE clock (now, accountCycles), vblankCount, the hardware
  registers (ioRead32 / ioWrite32: a port's own access), frameEnd, callLibrary, scratchpad, libraries, deterministic,
  realTime, setStorePatch. A port::Host is behind them.
- Overrides that run guest code (kernel.md section 3b): checkpoints charge, no event is taken in place; an event due,
  a call that blocks, a jump through a register, an inner call's return and a recursive call's return make guest code
  leave the override there, the stop deferred to its end (Dispatcher::beginOutcall / leave / takeDeferredStop); the
  override's own code runs on, as the reference's did; no exception goes through it. Every rule settled on a record.
- Generated code: bozo::checkpoint and bozo::innerReturn return true when guest code leaves, the check after each
  call tests ctx->leaving, a recursive call's return inside an override calls bozo_leave; ctx->outcall,
  ctx->leaving; the externals table (<prefix>_external_table); "store 0xADDR" externals (the store sets ctx->pc first).
- bozo-externals (tools/externals): the --externals list from the ELF's symbols BozoEngine answers, a port's stub names
  and its override list; --check compares the stubs with a call log's.
- bozo-run as a library (bozo_run, run_main.h): a port's checker links it with its generated code and overrides,
  which run natively (--overrides native|log); LogHost checks each call (context words, memory runs, traced calls, the
  operations and frame end inside, where it left) and pins where the reference's override left and whether a timed
  call inside it waited. The renderer's draw lists fill the record's draws (reported).
- The free host (runtime/host/free_host.cpp, bozo_host): every out-call native, libraries bound by the ELF's symbols,
  free timing, a watchdog when no frame ends.
- Moved from the team's fork code (phase4-inventory.md 2.1, MIT headers): the renderer's game side
  (bozo/render/renderer.h, renderer.cpp: headless, recording the published lists and their hash), Texture,
  the texture and mesh packs, mesh_draw, the movie picture hook, the FramePacer (unpaced off real time) and
  determinism.h (settable by the host).
- Libraries, from what only ran inside overrides before: sceGsExecLoadImage (0, no upload), T8H/T4HL/T4HH image tags as
  32-bit texels, the GS CSR's FIELD, sceSifSetDma raising SIF0's DMAC interrupt, CPCOND0 counting completions from
  the last FlushCache, a port's own register accesses, RotateThreadReadyQueue returning 0, libmpeg calling the movie
  picture hook, PadState::multitap.
- BOZO_BUILD_TOOLS (zlib-free configure for a port), the tests only when top level.

Results: TMB boot --pinned with every override native, 3000 of 3000 frames and 4,650,558 of 4,650,558 records (ram,
scratchpad, calls, threads); match1p: see docs/phase4-m0-notes.md. bozo-run without a port still matches.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 11:02:09 +01:00