mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 13:58:43 +00:00
The translator handles the image atomics, image_get_resinfo, image_get_lod and the 32-bit image_bvh_intersect_ray, but no test ran them. Six hand-written fixtures now do, with the expected words derived in each header from the RDNA2 ISA definition of the instruction: - cs_imgatomic: add, sub, and, or, xor, smin, smax, umin, umax and cmpswap on a 2D r32 uint image. 0xfffffff0 tells the signed min/max from the unsigned ones, each with a case that goes the other way; cmpswap hits and misses; one op runs without glc; 63 lanes are off; 64 threads add to one texel. - cs_imgatomic3d: six cases on a 4x4x4 volume, the 3D path of the translator. - cs_resinfo: a 16x4 image with five levels: levels 0, 1 and 3 in full, then dmask 0x3, 0xa and 0x8. - ps_get_lod, ps_get_lod_array: calculated LOD 1 and 3 on the two-mip texture, the clamped LOD held by the last level and by the sampler's MAX_LOD; 2 and -3 on the one-level 2D array. - cs_bvh32: the scene of cs_bvh through the 11-dword address form. vk_store_test gets a "words" mode for the compute ones: it also binds the uint image and a small volume as r32ui storage images (bindings 4 and 7) and a 16x4 five-level image behind its real T#, fills the images and prints them; check.py holds the expected words. The other two run on vk_texture_test and vk_compute_test as they are. All pass on an RX 7900 XTX and a Ryzen 9 7950X3D integrated GPU (RADV, Mesa 26.3.1) and on llvmpipe, natively and with LEONIDA_W64_EMULATE=1, and are clean under the validation layer. No translator change was needed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
33 lines
2.4 KiB
NASM
33 lines
2.4 KiB
NASM
; image_get_lod: the LOD an implicit sample at these coordinates would use. RDNA2 ISA (MIMG): the result is
|
|
; {rawLOD, clampedLOD} in VGPRs 1..0, so the first register gets the clamped LOD (after the sampler's and the image's
|
|
; limits) and the second the calculated one before any clamp; dmask keeps one or both, packed.
|
|
; Run: vk_texture_test vs_ids.spv ps_get_lod.spv out.raw 0 92 <S# word 1> 14500000 0 --two-mip, twice.
|
|
; --two-mip draws 64x64 pixels over a 128x128 texture that has two levels, and vs_ids runs u and v from 0 to 1 over
|
|
; the image, so a pixel step is two texels each way: the calculated LOD is log2(2) = 1. The second and third query
|
|
; scale u by 4: eight texels a pixel along x, two along y, and the larger one counts: log2(8) = 3, which no level
|
|
; of this image reaches, so its clamped LOD stops at the last level, 1. The S# is read from the heap behind the T#;
|
|
; its word 1 holds MIN_LOD [11:0] and MAX_LOD [23:12] in 4.8 fixed point, and its mip filter is point (word 2).
|
|
; mrt0 = (clamped LOD, calculated LOD at (u, v); calculated LOD alone at (4u, v); clamped LOD alone at (4u, v))
|
|
; S# word 1 = 0xc00000 (LOD 0..12): 1.0 1.0 3.0 1.0
|
|
; S# word 1 = 0x40000 (LOD 0..0.25): 0.0 1.0 3.0 0.0 MAX_LOD limits the clamped LOD to 0.25, and a point-filtered
|
|
; sample at 0.25 uses level 0; the calculated LOD is not limited
|
|
; Every pixel must hold these within 1/16 (a device may keep as few as four fraction bits of LOD).
|
|
; The second range is not 0..0: Mesa llvmpipe 26.3.1 does not apply a sampler whose minimum and maximum LOD are equal
|
|
; to an LOD query (it gives 1.0 there, where RADV gives 0.0), which says nothing about the translation.
|
|
; Not shown by this test: u and v taken in the wrong order. The texture is square, where the LOD is the same either way.
|
|
v_interp_p1_f32_e32 v2, v0, attr0.x
|
|
v_interp_p2_f32_e32 v2, v1, attr0.x
|
|
v_interp_p1_f32_e32 v3, v0, attr0.y
|
|
v_interp_p2_f32_e32 v3, v1, attr0.y
|
|
s_load_dwordx8 s[8:15], s[0:1], 0
|
|
s_load_dwordx4 s[16:19], s[0:1], 0x20
|
|
s_waitcnt lgkmcnt(0)
|
|
image_get_lod v[4:5], v[2:3], s[8:15], s[16:19] dmask:0x3 dim:SQ_RSRC_IMG_2D
|
|
v_mul_f32_e32 v8, 4.0, v2
|
|
v_mov_b32_e32 v9, v3
|
|
image_get_lod v6, v[8:9], s[8:15], s[16:19] dmask:0x2 dim:SQ_RSRC_IMG_2D
|
|
image_get_lod v7, v[8:9], s[8:15], s[16:19] dmask:0x1 dim:SQ_RSRC_IMG_2D
|
|
s_waitcnt vmcnt(0)
|
|
exp mrt0 v4, v5, v6, v7 done vm
|
|
s_endpgm
|