Repository navigation
feat(shader,gpu): move 16-bit typed buffer channels bit-exactly through unsigned twin views - #407
Open
gdemontalivet wants to merge 1 commit into
Open
gdemontalivet wants to merge 1 commit into
gdemontalivet wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On the console GPU, a typed buffer descriptor carries
NUM_FORMAT(FLOAT,UINT,SINT, …) in the descriptor itself rather than in the shader instruction, and deformation/morph shaders (such as facial and mouth blendshape passes) move 16-bit channel patterns bit-exactly through two idioms:buffer_load_format_d16_*/buffer_store_format_d16_*instructions, orbuffer_load_format_{x,xy,xyz,xyzw}/tbuffer_load_format_*loads whose destination registers are consumed exclusively as 16-bit half-floats (v_cvt_f32_f16orv_fma_mix*withop_sel_hiset)—expecting the console'sUINTview to return zero-extended 16-bit bit patterns in the low half of each VGPR.When the host binds a
16-bitFLOATorSINTtyped buffer view (R16_FLOAT,R16G16_FLOAT,R16G16B16A16_FLOAT, or_SINT) to a DXILBuffer<uint4>(VIEW_INTEGER) orBuffer<float4>handle, D3D12 / Metal either converts float values to integer, canonicalizes/flushes subnormal and signaling-NaN payload bits, or mismatches the view's return type—corrupting packed 16-bit vertex deltas and blendshape weights.What changed
victory-shader/src/emit/half_views.rs,lower.rs,ir.rs,mod.rs,shader_cache.rs):emit/half_views.rs(keepingcrates/victory-shader/src/emit/lower.rstrimmed to514,608 B—9,680 Bbelow the524,288 Bpolicy cap) and addLower::places_read_as_halvesto find(root_slot, table_dword_offset)descriptor places where every static access is either a_format_d16_buffer op or a whole-dword format load whose results are read exclusively as 16-bit halves (read_only_as_halves, following phis and ignoring lane-preserving partial-EXEC register reads viair::operand_reads), excluding any place also accessed as plain floats/raw words or any table dynamically indexed at run time.half_viewsplaces throughVIEW_INTEGER(Buffer<uint4>/RWBuffer<uint4>) so 16-bit channel bits travel unconverted, and serializeHostShader::half_viewsin the shader cache (VSH3).victory-gpu/src/descriptor/host.rs,descriptor.rs,draw.rs):FLOATandSINTbuffer SRVs/UAVs (placed and unplaced: formats10/14->12R16G16B16A16_UINT,34/38->36R16G16_UINT,54/59->57R16_UINT) to unsigned integer twin views viadescriptor::host::half_viewwhen building fresh dynamic descriptor tables for shaders with non-emptyhalf_views, sizing the dynamic table allocation to coverhalf_viewsslots pastUsedResourcerange starts and logging any format whose console conversion is non-identity (half_inexact).How it was tested
wave32=true), isolated test bottle:cargo test --workspace(native macOS): all passed (0failed).--test-threads=1):victory-shader: all passed (0failed), including hardware/WARP execution tests verifying bit-exact preservation of subnormals, negative zero, NaN payloads, and signed 16-bit patterns acrossd16and whole-dword half-float loads/stores, mixed-access exclusion, and dynamic-table exclusion.victory-gpu:77descriptor & draw D3DMetal tests passed (0failed), includingonly_16_bit_float_and_signed_buffer_views_get_an_unsigned_twinanda_fresh_table_holds_the_half_views_past_its_range_starts.cargo xtask policy(260 files ok,lower.rsat514,608 Bwith9,680 Bheadroom below524,288 B),git diff --check, andcargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings(with and without--features diagnostics,0warnings): clean. All test inputs are synthetic.Live M5 Max Verification (Combined Build on CrossOver Preview + D3DMetal)
CrossOver Preview+ D3DMetal,wave32=true), the runtime reached and sustained the 3D world through+8, +24, +48, +90at1.5–1.8 FPS(549.7–672.1 ms/frameon1,021–1,258 draws/frame,1.275 FPSoverall across+8..+90) with02.48 sallocation stalls,7.2–9.0 ms/frameGUARDSlock hold time (down from4,887 ms/framebefore unlockingGUARDS),149–154 MB/framebuffer copy volume,0DirectStorage decompression or access-violation failures, and38/38over-32 KiB aligned mesh/pixel pairs linked with0host mesh refusals.