Breath of Fire: Dragon Quarter's memory card picture is a sprite drawing the
frame so far into the GS memory, in the middle of a frame whose end is a
black fade tile: the presented picture (readPicture) is black. Natively the
port copies the frame so far into an auxiliary image there (fromFrame,
source 0) and reads that image back.
Renderer::readImage(image, width, height, rgba, timeoutMs) asks the first
present showing the frame published when it was called (or a later one) for
the auxiliary image as the frames drawn so far left it: all of it, one
ReadPixels, rows top-down as the screen's, RGBA (alpha 0x80), and its size.
Called on the game's thread after the frame drawing into the image was
published. False at once when nothing has presented in the last second
(headless), for an image no frame has drawn, and on a timeout.
GPU test (BOZO_APP, label gpu): a frame red over blue is copied into image 2
(8 x 6), then covered black; another thread reads the image back (red over
blue, top-down) while readPicture gives the black frame; an image never drawn
reads false.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Material::destinationAlpha (Off / Clear: pass where the target's alpha is below
0x80 / Set: 0x80 and up): the target so far copied to unit 4 before the draw (3 being the shader blend's destination),
its alpha tested per fragment (0x80 is the 1.0 the target keeps).
- Material::frameAlpha: an opaque draw writes its own alpha (As) instead of 1, as
the GS does, so a later DATE or DST_ALPHA blend reads it.
Both default off: other ports draw as before.
Breath of Fire: Dragon Quarter's character outlines: an inflated dark mesh drawn
with DATE, DATM 1 where the frame's alpha is set, not over the characters (alpha 0).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The GPU blender has no factors for a colour times 1 + C (A = D, B = 0: ALPHA 0x49 Cd x (1 + As), 0x08
Cs x (1 + As)); applyGsBlend dropped the C term, so such draws did nothing (0x49) or lost their base (0x08).
They now blend in the shader against a copy of the target (the GS-arithmetic path), with the source alpha read
before the 1.0 clamp (the GS's As can exceed 0x80). Rare: a few draws a frame.
VP2S battle 0x8f (Dark Savior): the golden ground ring's 0x49 draws were invisible; they now brighten as on PCSX2.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
With setGsArithmetic on, a gsBlend draw that reads an image (fromFrame with a source) copies its target and
blends in the shader with the GS's byte rules: floor((A - B) x C / 128) + D, C the truncated source or target
alpha or FIX. The GPU blender cannot truncate; with small factors (VP2's title glow layers at alpha 3..4)
that is most of the result. A few full-screen layers a frame.
VP2S title glow vs a GS-rule render of PCSX2's dump: ours added 11.6/12.4/13.3 per channel, PCSX2 7.3/8.6/9.1;
now 7.0/8.4/9.0.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
With setGsArithmetic on, image passes (frame copies, filters, levels, chains) store their result as truncated
bytes, as each GS pass does, where the 8-bit target would round to nearest. Scene draws are unchanged.
VP2S's world-map glow measured against a GS-rule render of PCSX2's dump: the full frame was +3.3..+4.0 per
channel over PCSX2, now +0.9..+1.8 (with a VP2S-side split of the glow level pass).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Steambot Chronicles' menus are drawn over a half-size copy of the screen
(sceGsExecStoreImage of the frame buffer). Renderer::readPicture asks the
next present for a rectangle of the frame's screen, read back with one
ReadPixels after the picture is drawn and before the window draws over it,
box-averaged to the size asked for (RGBA, rows top-down, alpha 0x80). It
waits up to a timeout for that present and answers false at once when
nothing has presented in the last second (headless).
GPU test (BOZO_APP, label gpu): a hidden window presents red and blue
halves while another thread reads them back at 4 x 2.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Renderer::setGsArithmetic(true) makes textured scene draws compute as the GS does: the filtered texel and the
interpolated vertex colour as truncated bytes, modulate floor(T x C / 128), fog (F x C + (255 - F) x FOG) >> 8.
Off by default (exact float, rounded once on store). Image passes are unaffected.
VP2S measured a town frame against a GS-rule render of PCSX2's dump of the same frame: exact arithmetic is
+2.2 per channel over the GS (doubled by the game's 2x pass); with this, +0.4.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
When a player installs ReShade (its opengl32.dll beside the executable), the
program registers as one of its add-ons and has it render its effects inside
present(), after the 3D picture and before the HUD and menus, so a colour
grade, depth of field or ambient occlusion no longer goes over the 2D. The
F2 / F3 panels stay clear too. Without ReShade nothing changes;
BOZO_RESHADE_AT_PRESENT=1 keeps ReShade's own pass over everything.
- Renderer::setBeforeOverlay: a hook present() calls when it draws to the
window, between the 3D and the 2D, with the window's size; present()
binds its own state again afterwards.
- app/reshade_bridge: registration after the window is made (ReShade's DLL
loads with it) and before the GL context; the effects run on a texture
of the window's size, copied upside down from and back to the window, as
ReShade's own OpenGL pass does (its effects expect the top row first).
- ReShade 6.8.0's API headers (BSD-3-Clause) in app/reshade/.
- MinGW and ReShade's MSVC return structs from methods differently, so no
API method returning a struct is called; views are built as ReShade's
OpenGL backend makes them.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The 3D target (window size x render scale) was drawn to the window with bilinear
filtering, which reads 2 x 2 texels. At scale 3 each window pixel's centre falls
on the middle texel of its 3 x 3 block, so it read that one alone: the picture was
the one of scale 1 (Shinobido: 1% of pixels differed, none by much); at 4 it read
2 x 2 of 16.
The flat shader gets a box filter (uBox, uFoot): for a render scale over 1 the
present draws the target with ceil(scale) x ceil(scale) bilinear taps spread
across each window pixel's footprint, at a whole scale the scale x scale texels
exactly. Scale 1 and under draw as before (Shinobido at 1: the same picture, pixel
for pixel). Scales 2, 3 and 4 now give smooth edges without blur.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
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]>
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]>
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]>
The frame's 3D is drawn into a multisampled colour and depth-stencil of the
target's size and resolved into the single-sampled target wherever the frame
is read: the copies a material samples, the depth an image pass reads, an
auxiliary target sharing the frame's depth, the depth tiles and the present.
Off by default; video.ini anti_aliasing, PS2X_ANTI_ALIASING (also read by
scripted runs). A size or sample count the GPU refuses falls back to none.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Renderer::setTextureSmoothing(0 off, 1 trilinear, 2..16 anisotropic): a frame
draw whose material has no mip levels of its own samples levels generated from its
texture, by the screen footprint. Off by default (as the GS samples a texture
without levels). video.ini texture_smoothing / PS2X_TEXTURE_SMOOTHING and a combo
in the Video tab.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
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]>
- 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]>
SndDriver::serialize saves the driver's banks, handles, slots and replies' state,
then its engine:
- the IOP memory and clocks;
- the mixer (Mixer::serialize) and libsd;
- 989SND's model (snd989::Engine::Impl). Its pointers are saved as data: a byte
of a bank as (bank, chunk, offset), a handler as (table, index), a MIDI as
(bank, index), a stream buffer as its index.
A load makes the engine when the state has one and anchors the real-time clock
again. Libraries::unsaveable no longer refuses for 989SND.
Engine::bankUnloaded destroyed the bank while busy voices still pointed into its
header: the program record that voiceVolPan reads again for SetSoundParams, a
use-after-free. Unloaded banks are kept in `retired` (headers only; 989SND reads
IOP memory, which stays until reused), so those pointers stay valid and can be
saved.
LoadedImages::images / restore let a port save the NGP files it bound.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
A batch can now ask for CLAMP's region clamp on either axis (JC2's projected
room texture uses CLAMP 5); the submitter passes it to the material.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Auxiliary images go from 8 to 16 (Material::kAuxiliaryImages);
kPreviousFrame stays 8. Images 9..15 are targets like 1..7: an image
keeps its pixels until a draw into it in a later frame. A game's frame
snapshot (VP2S's capture fade, mod003 class 1610f0) is copied once from
the previous presentation, then sampled while it fades, without
colliding with the targets other effects redraw every frame.
The render-target test copies the previous frame into image 12 and
samples it in the next two frames, including a repeated presentation.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
- F2 > Video gets a "Texture pack" checkbox when the player has a pack:
on / off (texture_pack = off), applied at once.
video::texturePackFolder() resolves the setting for the panel and apply.
- A larger copy (replacement or upscaled) already on the GPU is shared by
the copy object: a slot whose key changed for the same texture (TMB's
texture manager moves textures in VRAM, so their TEX0 changes) takes it
instead of sending it again. Unused copies stay up to 512 MB (LRU) and
are dropped when the replacements change.
- Larger uploads are limited to 4 MB a present (was 12): a full pack's
first 150 MB at a match's start no longer stalls presentation.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The upscaler's and the replacements' worker threads now run at the
lowest thread priority (Windows THREAD_PRIORITY_LOWEST, nice 10
elsewhere), so making a level's copies never takes a core from the game
or the present thread. A texture whose replacement is being read no
longer gets an upscaled copy too (with a full pack every texture was
made twice at a level's start). PS2X_TEXTURE_STATS also counts the
uploads since its last line.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
<identity>.png files (textureIdentity: the draw-list hash's texture
identity), the texture's size or 2, 4, 8 times it, read by worker threads
with a dependency-free PNG reader; a replacement takes precedence over
texture upscaling. texture_pack in video.ini, PS2X_TEXTURE_PACK, the user
folder's texture_pack by default; PS2X_TEXTURE_PACK_RELOAD=1 rescans.
For 60 fps: larger copies (replacements and upscaled copies) sent to the
GPU are limited to 12 MB a present. Without it TMB's 1P route at 4x
upscaling fell to 31 presents/s for ~20 s while its arena's copies
arrived; with it, it holds 60. A material without mip levels samples a
larger copy down to the texture's own size, so distant draws neither
alias nor cost more bandwidth.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replicated texels, filtered by the GPU, made painted textures (Soulcalibur
III's Tales of Souls map) blockier than the texture drawn as it is. A texel
with no diagonal edge is now interpolated as the smooth filter does; flat
areas stay exact.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Renderer::setTextureUpscale draws a Texture marked asset (decoded from the game's
own data: packs::decodeRecord sets it) from a copy 2x or 4x as large, made by
worker threads and kept by content; until it is made the texture is drawn as it
is. Two filters written from the published method descriptions: edge-directed
(xBR family, exact coverage per output texel) and Catmull-Rom with no ringing,
both premultiplied by alpha. A repeating texture is scaled with the opposite
edge as its neighbour. The game's mip levels sit k levels down and a level
chosen from Q or fixed moves with them. Off: the same GL calls as before.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
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]>
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]>
Enable the original game's heat distortion by default, retaining BOZO_HEAT_HAZE=0 for comparisons.
Measure movie cadence, correct the FMAC overflow tests, and keep temporary-context timer/checkpoint accounting
separate from the running thread. Pin recursive events at their exact recorded cycle/checkpoint when the
reference's context pc retains an inner caller. Add Windows and Linux CI for the native test suite.
Co-Authored-By: Codex <[email protected]>
TMB's lens flares ask for the depth around every flare (Renderer::depthAt): in a night arena with headlights,
200-300 tiles a present on average and up to 1,400. readDepthTiles made one ReadPixels a tile into one pixel-pack
buffer and mapped that buffer at the next present. The window thread spent ~70% of its time blocked there (the
profile: win32u waits under readDepthTiles), and the presents fell to 14-45 a second in a 1P match while the game kept
60 (the user's report: 15 presents/s in a 2P night arena).
- Three buffers, each read fenced (glFenceSync); a present takes the newest read whose fence has passed
(glClientWaitSync with timeout 0) and never waits: with every buffer in flight it reads nothing and depthAt keeps
the tiles it has (a frame or two later, which the flares tolerate).
- The tiles are read by runs along each tile row (neighbours up to two tiles apart joined): one ReadPixels a run.
- The target's depth is DEPTH24_STENCIL8 and read as DEPTH_STENCIL / UNSIGNED_INT_24_8 (the hardware's own format),
converted to [0, 1] as d / (2^24 - 1), what the float read gave.
1P match at 1280x960, render scale 2: presents 60.0 a second throughout (min 55.5 with a sampler attached), against
13.9-60 before (32 of 65 two-second stretches under 55).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>