D3D7 processed vertex-buffer clipping and extents — 2026-11-05

Task base: fbc8051625bca534bc8a8534cf8e641d9ada393e. Evidence: scratch/runs/20261105-d3d7-processvertices-clip-extents/. Both public processing methods now implement six-plane CLIP and screen EXTENTS2. Their ordinary/indexed VB consumers retain homogeneous clipping coordinates separately from the final viewport depth. Native Windows equivalence remains unqualified.

Primary contract and version boundaries

The preserved Microsoft DX7 SDK pages, built 1999-09-02, explicitly allow TRANSFORM combined with CLIP, EXTENTS, and LIGHT on both ProcessVertices and ProcessVerticesStrided. TRANSFORM is mandatory. CLIP requires a destination with clipping support. The overview describes optional generation of clip flags and extents during processing, and forbids processing locked source/destination buffers. It also defines DONOTCOPYDATA as leaving uncomputed components untouched. See Processing Vertices.

The method-page EXTENTS sentence mixes processing with later rendering. The overview explicitly places updates during processing; the method says GetClipStatus does not account for these vertices again when rendered. Consequently the implementation must accumulate during processing and avoid recounting at draw. This is an interpretation of the two primary passages, not a native Windows observation. No primitive topology is supplied at processing time, so CLIP generates retained per-vertex information; edge intersections belong to the subsequent ordinary/indexed VB draw.

The DX7 factory method requires zero dwFlags. Its remarks distinguish the older IDirect3D3 factory. The creation overview still discusses that older four-argument factory and its D3DDP_DONOTCLIP argument; it is not authority for accepting that flag on the DX7 factory. D3DVERTEXBUFFERDESC defines D3DVBCAPS_DONOTCLIP, which genuinely prevents retained clip information. Preserve an invalid-format result for CLIP on that destination, rather than manufacture successful output.

Clipping Volumes puts clipping in homogeneous projection space, and specifically distinguishes VB processing from the general CLIPPING render state. The personally inspected SDK formula image clipfrml.gif specifies strict lower bounds (-W<X, -W<Y, 0<Z) and inclusive upper bounds (X<=W, Y<=W, Z<=W); no viewport-depth inversion can recover it when MinZ equals MaxZ.

D3DCLIPSTATUS defines union/intersection flags and EXTENTS2; EXTENTS3 is explicitly unimplemented. Do not invent 3D extents. Render states describe EXTENTS as the rendering-call switch, distinct from the explicit processing operation. The strided overview disallows transformed source streams; its twelve pointer/stride pairs and FVF specify component layout, not a source index. The PVS method page's source-index label is stale; the public d3d.h ABI takes source FVF there.

Exact downloaded inputs and SHA-256 values are recorded in sdk-inputs.json. Source reconstruction uses Git SHA plus relevant binary diff and owned new-file patches; no source archive, module copy, or media copy.

Inspected implementation and public consumers

Ordinary ProcessVertices accepted but ignored CLIP/EXTENTS. Strided processing returned E_NOTIMPL for either. The generated VB7 ordinary alias reaches the shared ordinary handler; both stack handlers and Device7 draw slots 31/32 were inspected.

The current clip-status helpers copy 24 bytes at device +4000. That covers flags/status and four 2D extrema. Device +4024 owns the texture-transform block pointer; +4028 owns the immediate-mode descriptor. Increasing the memcpy to the SDK structure's 32 bytes would overwrite live pointers. Immediate-mode code additionally snapshots/restores the same 24 bytes. Execute-buffer status is separate D3DSTATUS storage, not the Device7 GetClipStatus record.

vertex_project retains homogeneous normalized clip XYZW at device +4064 and writes a distinct projected TL record. process_viewport_depth maps only final TL Z. Private per-VB records retain clip XYZW and homogeneous screen XYZ; they are outside the public FVF/Lock/descriptor sizes and are released with the VB. Draw consumers clip against the original six planes, interpolate attributes before perspective division, and publish canonical owned vertices through the existing queue. MinZ*W+(MaxZ-MinZ)*clipZ remains separate from the original clipZ; collapsed viewport ranges therefore do not destroy clipping information.

The implementation covers the six standard planes, point/line/list/strip/fan assembly, and relative indexed ranges. Device7 GetCaps currently advertises wMaxUserClipPlanes=0 (WORD at212). The public fixture pins that limit. Enabled application-defined clip planes remain explicit E_NOTIMPL; the SDK permits user planes on capable devices, so this is the advertised emulator limitation rather than a blanket SDK prohibition. Clip-disabled processing invalidates retained records for the overwritten range. Locks retain private flags for inspection; arbitrary application replacement of processed positions without reprocessing has no native qualification here.

Both methods acquire all fallible processing allocations before modifying output, retained records, or clip status. Explicit operations establish valid output fields: absent STATUS starts from the SDK's documented D3DSTATUS_DEFAULT, and absent EXTENTS2 starts from the first processed point. Existing valid fields accumulate from the caller's SetClipStatus seed. SetClipStatus rejects the explicitly unimplemented EXTENTS3 without changing the supported fields; GetClipStatus does not interpret uninitialized caller output bytes as input flags.

Validation and limits

The required RF0940 then Strong0950 final releases were observed before shared edits or executable checks. release-gate.json independently verifies predecessor process/watcher identities, absent profiles, closed ports, free runtime/build locks, and free disk. No tests or shared implementation ran during source preparation.

Validation on both shipped modules:

Final browser artifacts and capture review are recorded in result.json and capture-review.json. Full-page captures are accompanied by native PNG exports from the original public-surface readback canvases, without redrawing/scaling/image processing. Earlier browser-05 element screenshots exposed black GPU-mode figure captures despite agreeing public Lock and actual gl.readPixels; those exploratory captures are preserved rather than treated as rendered successes.

Tested modules: wine-assembly.wasm SHA-256 f4e787c6d8de50bfe00137fe4026c2fac8f01a1e6f476c3bc01d7626c2bee185; compat SHA-256 32c8eaeeb4e23fed1898b09cb7e5d198550cba549c6974d8d2f0e6480146eb06. tested-source.json and the relevant binary diff/new-file patch preserve source provenance; modules/media remain referenced by existing path and SHA, not copied into the run.

Actual browser: Chrome 151.0.7922.108, WebGL2, reporting ANGLE Intel UHD Graphics 620 / Mesa 23.2.1 in both direct and production Worker records. Launcher flags request SwiftShader, but the observed renderer string is Intel/Mesa; do not label the run SwiftShader. Physical GPU provenance is not independently established, and no native Windows runner is assigned. Point/line rendering controls exercise the existing software path; GPU controls exercise triangles. Historical27, computed-alpha conversion, and nonuniform-normal behavior remain unqualified. No original games, subworkers, external boxes, or public deployment are used. Coordinator retains runtime lifecycle ownership; box ID/state/expiry are not applicable.