Repository navigation
d3d12_xs: map console texture D3D12_BARRIER_LAYOUT initial states on committed and placed resources - #9338
d3d12_xs: map console texture D3D12_BARRIER_LAYOUT initial states on committed and placed resources#9338TheAirborneCoder wants to merge 5 commits into
Conversation
… RENDER_TARGET or DEPTH_WRITE
…so the state map is checked with the riid and output in place
…VC leaves the upper half of the stack slot), and else-branch the generic forwarder (C4702); found by MartinIndra02 on ItsNotRexed#7356
…S (CLAIM 7110346733) Stacked on ItsNotRexed#7356's pc_initial_state_word. Barrier layout 0x3 was refused as buffer-only bits; with ALLOW_UNORDERED_ACCESS it becomes UNORDERED_ACCESS.
…committed and placed resources Console CreateCommittedResource (slot 27), CreatePlacedResource (slot 29), CreateCommittedResource1 (slot 53) and slot 76 pass a D3D12_BARRIER_LAYOUT ordinal in the initial-state word rather than a legacy D3D12_RESOURCE_STATES mask. On textures (TEXTURE1D / TEXTURE2D / TEXTURE3D), most barrier-layout ordinals carry buffer-only or conflicting bits that PC D3D12 rejects with E_INVALIDARG (such as layout 6 SHADER_RESOURCE on placed BC4_UNORM textures). Route slot 29 CreatePlacedResource through pc_initial_state_word alongside slots 27, 53 and 76 (keeping 7-word forwarding for slots 27 and 29 separate from 8-word slot 53), and map all unambiguous texture D3D12_BARRIER_LAYOUT ordinals to PC D3D12_RESOURCE_STATES gated by the resource flags each layout requires, disambiguating ordinals 4 (RENDER_TARGET vs DEPTH_STENCIL_WRITE) and 8 (UNORDERED_ACCESS vs COPY_DEST) by Flags while leaving buffer and non-colliding PC texture states untouched. Claim: ItsNotRexed#8683 (comment 7111877498) Depends on: ItsNotRexed#7356, ItsNotRexed#8384
rideinstead
left a comment
There was a problem hiding this comment.
Leonida automated security-monitor note
The static monitor found items that need maintainer inspection. These are heuristic signals, not confirmed vulnerabilities.
Findings
- LOW — Sensitive terminology at
runtime/shims/d3d12_xs_device.cpp:1478
Evidence:// Valid PC texture state masks (0x10 DEPTH_WRITE, 0x20 DEPTH_READ, 0x40/0x80/0xC0 shader reads, etc.) and all
Diff-only heuristic scan; contributor code was not executed. This is advisory and does not replace maintainer review.
abnalstlll-byte
left a comment
There was a problem hiding this comment.
Independent Windows & MSVC Review
What changed:
runtime/shims/d3d12_xs_device.cpp:- Maps console
D3D12_BARRIER_LAYOUTinitial-state ordinals to PCD3D12_RESOURCE_STATESonCreateCommittedResource,CreatePlacedResource, andCreateCommittedResource1. - Disambiguates ordinals 4 and 8 using resource flags, avoiding
E_INVALIDARGrejections on texture creations.
- Maps console
Verification on Windows 11 host:
- Build passes under MSVC 19.44 / CMake.
device_proxy_testandxs_proxy_mock_testpass all barrier layout checks.- Clean diff: no game files.
LGTM!
rideinstead
left a comment
There was a problem hiding this comment.
Correction — false positive
Please disregard the previous automated note. It was triggered solely by the word shader in a descriptive comment about D3D12 texture-state masks. That is ordinary graphics terminology, not a security indicator. This finding did not identify suspicious behavior. The keyword-only terminology rule has been removed from the monitor.
|
Tested 575e7a0 on NVIDIA GeForce RTX 4080 SUPER, driver 621.24 (Vulkan 1.4.357), Windows 11 Pro 26300, MSVC 14.44, Ninja RelWithDebInfo (fresh build folder), applied on
(AI-assisted check, Claude Code.) |
Claimed in: #8683 (comment)
Depends on: #7356, #8384
Summary
Following
#7356and#8384, @Jadiac5's live boot trace on#8344hitE_INVALIDARG(0x80070057) inCreatePlacedResource(device slot29) for a512x512BC4_UNORMTEXTURE2DwithFlags == 0and initial state0x6(D3D12_BARRIER_LAYOUT_SHADER_RESOURCE):29(CreatePlacedResource) was not yet routed throughpc_initial_state_word(only slots27,53, and76were).pc_initial_state_wordonly handled layouts3(RT+UAV) and4(depth-stencil), leaving0x6(D3D12_BARRIER_LAYOUT_SHADER_RESOURCE, whose bits0x2 | 0x4mean buffer-onlyINDEX_BUFFER | RENDER_TARGETin legacyD3D12_RESOURCE_STATES) and the remaining textureD3D12_BARRIER_LAYOUTordinals unmapped.This change:
29(CreatePlacedResource) throughpc_initial_state_wordvia a 7-argumentproxy_create_resource_state7<Slot>shared with slot27(CreateCommittedResource), keeping 8-argumentproxy_create_committed_resource1separate for slot53so 7-argument calls never toucha8, and marks slot29inslot_name()/device_slot_overridden().pc_initial_state_wordacrossTEXTURE1D/TEXTURE2D/TEXTURE3Dusingleonida::d3d12_layout(runtime/src/command_list.h), disambiguating the two ordinals (4and8) whose numeric values overlap valid textureD3D12_RESOURCE_STATESbits viadesc->Flags:0xFFFFFFFF(UNDEFINED),18/24(DIRECT/COMPUTE_QUEUE_COMMON) ->D3D12_RESOURCE_STATE_COMMON(0)1,19,25(GENERIC_READ) ->D3D12_RESOURCE_STATE_GENERIC_READ(0xAC3)2(RENDER_TARGET) withALLOW_RENDER_TARGET->D3D12_RESOURCE_STATE_RENDER_TARGET(0x4)3,20,26(UNORDERED_ACCESS) withALLOW_UNORDERED_ACCESS->D3D12_RESOURCE_STATE_UNORDERED_ACCESS(0x8, covering UAV-only as well as RT+UAV textures)4: withALLOW_DEPTH_STENCILand notALLOW_RENDER_TARGET, mapsDEPTH_STENCIL_WRITE->D3D12_RESOURCE_STATE_DEPTH_WRITE(0x10); withALLOW_RENDER_TARGET, preserves legacy0x4(RENDER_TARGET)5(DEPTH_STENCIL_READ) withALLOW_DEPTH_STENCIL->D3D12_RESOURCE_STATE_DEPTH_READ(0x20)6,21,27(SHADER_RESOURCE) withoutDENY_SHADER_RESOURCE->D3D12_RESOURCE_STATE_ALL_SHADER_RESOURCE(0xC0)7,22,28(COPY_SOURCE) ->D3D12_RESOURCE_STATE_COPY_SOURCE(0x800)8: withoutALLOW_UNORDERED_ACCESS, mapsCOPY_DEST->D3D12_RESOURCE_STATE_COPY_DEST(0x400); withALLOW_UNORDERED_ACCESS, preserves0x8(ambiguous with legacyUNORDERED_ACCESS, which PC D3D12 accepts);23/29(DIRECT/COMPUTE_QUEUE_COPY_DEST) ->D3D12_RESOURCE_STATE_COPY_DEST(0x400)9(RESOLVE_SOURCE) ->0x2000,10(RESOLVE_DEST) ->0x10000x10,0x20,0x40,0x80,0xC0,0x400,0x800, etc.) andDIMENSION_BUFFER/DIMENSION_UNKNOWN/ nulldescpass through unchanged.Testing
Tested on Windows 11 (
10.0.26200), MSVC19.51.36260.0(RelWithDebInfo,/W4zero warnings), D3D12 + WARP, NVIDIA GeForce RTX 5090 (driver32.0.16.1088) / AMD Radeon Graphics (driver32.0.21042.62):ctest --test-dir build -C RelWithDebInfo --output-on-failure:103/103runnable tests passed (0failures;7retail-package tests skipped whenLEONIDA_GAME_DIRis unset), including expanded mock coverage inruntime/test/xs_proxy_mock_test.cpp(7-word vs 8-word forwarding, all mapped ordinals, flag disambiguations,TEXTURE1D/2D/3D, non-colliding PC states, untouched buffers) and live WARP coverage inruntime/test/device_proxy_test.cppacross slots27,29(tier-safe heaps),53, and76(with raw WARP negative controls confirming unmapped0x6and0x8fail withE_INVALIDARGon512x512BC4_UNORMTEXTURE2DFlags=0).python -I scripts/check_no_game_data.py runtime/shims/d3d12_xs_device.cpp runtime/test/device_proxy_test.cpp runtime/test/xs_proxy_mock_test.cpp(clean)AI-assisted (Antigravity).