Skip to content

Count first uses of the pixel shader front-face input in cached listings - #6130

Open
kacper-serewis wants to merge 2 commits into
ItsNotRexed:mainfrom
kacper-serewis:census/front-face-first-use
Open

kacper-serewis wants to merge 2 commits into
ItsNotRexed:mainfrom
kacper-serewis:census/front-face-first-use

Conversation

@kacper-serewis

Copy link
Copy Markdown
Contributor

Claimed item PS-FRONT-FACE-FIRST-USE on board #6089. Independent CPU follow-up to #5237. Based directly on main at 561b65a with no PR dependencies.

Run python -I tools/ps_front_face_census.py <dxbc> --disasm <cached-listings>. Each indexed PS stem contributes once per category. The tool derives the candidate register from ISG1 and verifies the listing words against FSSM from the native entry. It follows direct branches and fallthrough until the first read, a recognized full write, termination, or uncertainty. Branch feasibility is unmodeled.

Whole private cache on Windows, CPU only. Of 26,503 indexed stems, 12,101 were PS, 1,984 declared front face, all 1,984 listings were examined, and 0 signatures were skipped. The historical first printed access was a read in 345 listings. Traversal resolved 264 readers (243 ne e32, 20 ne e64, 1 eq e32, each u32 against immediate zero), 5 without a read and 1,715 unresolved. Reasons overlap across paths: 707 possible lane-partial writes, 1,008 unknown flow/addressing, 8 unclassified destinations. These counts describe the candidate VGPR's uses. Its native bit pattern remains unmeasured by this tool.

Five synthetic cache tests passed via python -I tests/test_ps_front_face_census.py -v. Compileall and staged diff checks passed. No GPU/driver or raw package used. AI-assisted with Codex.

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

The census misses a first read in flat_store_dword at f04b0fc8. The instruction flat_store_dword v[4:5], v0 reads v4 and v5 for the address. It writes to memory. For a front-face input in v4, the expected result is ({'flat_store_dword'}, set()). The actual result is (set(), {'unclassified destination'}).

I assembled the instruction with llvm-mc -triple=amdgcn -mcpu=gfx1030 -show-encoding. Run this script from the repository root with py -3.14 -I -. It uses the eight bytes from that instruction.

import struct, sys
sys.path.insert(0, 'tools')
from shader_ir import parse_line
from ps_front_face_census import first_uses
ins = parse_line('flat_store_dword v[4:5], v0 ; encoding: [0x00,0x00,0x70,0xdc,0x04,0x00,0x7d,0x00]')
native = bytearray(0x128)
struct.pack_into('<I', native, 0xc0, 0x100)
native.extend(bytes.fromhex(ins['enc']))
print(first_uses(dict(code_start=0x128, code_end=len(native), insns=[ins]), native, 4))

reg_reads_writes() treats the first operand as a destination for this store. Please count the address operand as a read and add a regression test. The existing five census tests pass on Windows. The merge base 561b65a8 has no census tool.

AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants