Commit Graph

568 Commits

Author SHA1 Message Date
b1d7e41074 Fix the runtime build after the merge round: custom border colour chain, lds_bytes CLI check
- d3d12_vulkan_device.cpp, vk_test_device.h: #760 chained VkPhysicalDeviceCustomBorderColorFeaturesEXT onto
  enable13, which #1706 replaced with leonida::Vulkan13Features; it goes at *v13.next() like the other later
  feature structs. The runtime and the GPU test harness didn't compile.
- check_vk_pipeline_cli.cmake: #1958's lds_bytes cases matched "malformed JSON"; the index parser reports where it
  stopped ("... at byte 37"), which the check now matches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:14:21 -05:00
e65b624932 Merge pull request #2030 from itsRevela 2026-11-22 10:40:36 -05:00
81c6cfe4fd Merge pull request #2021 from jaybeebabageyus 2026-11-22 10:40:29 -05:00
8b310b2092 Merge pull request #1977 from Douglas Sposito 2026-11-22 10:40:03 -05:00
cd63047345 Merge pull request #1940 from Ryderadzeee 2026-11-22 10:39:35 -05:00
b6f759daa9 Merge pull request #1937 from SHAURYASANYAL3 2026-11-22 10:39:34 -05:00
dd91fbe6ff Merge pull request #1935 from Tao Battarel 2026-11-22 10:39:33 -05:00
9887cc773a Merge pull request #1924 from Ash Hopkins 2026-11-22 10:39:28 -05:00
8dc359b892 Merge pull request #1914 from zneel 2026-11-22 10:39:25 -05:00
4c2800bd27 Merge pull request #1912 from Nolan Cotter
# Conflicts:
#	docs/README.md
#	docs/d3d12_vulkan.md
#	docs/i18n/README.md
2026-11-22 10:39:23 -05:00
96dcddb6fb Merge pull request #1911 from Jan Trencansky 2026-11-22 10:39:21 -05:00
756bc62610 Merge pull request #1907 from Vonsek 2026-11-22 10:39:19 -05:00
53e46c0b8c Merge pull request #1886 from Claude 2026-11-22 10:39:10 -05:00
de8278f673 Merge pull request #1882 from Tomgamer 2026-11-22 10:39:08 -05:00
9fb466a137 Merge pull request #1820 from Tomgamer 2026-11-22 10:38:57 -05:00
0093aa9097 Merge pull request #1799 from Dominik 2026-11-22 10:38:54 -05:00
86e6848f7b Merge pull request #1756 from Leonardo Guimaraes 2026-11-22 10:38:52 -05:00
56ae397800 Merge pull request #1740 from Ryderadzeee 2026-11-22 10:38:51 -05:00
ae2a4a1705 Merge pull request #987 from gabrielsteglich 2026-11-22 10:38:46 -05:00
6edbf763d4 Merge pull request #899 from Dea7hsmiles 2026-11-22 10:38:45 -05:00
03d81593b5 Merge pull request #831 from TheHoracio 2026-11-22 10:38:43 -05:00
1e48c3f463 Merge pull request #760 from 0xTehuti 2026-11-22 10:38:41 -05:00
7f9b28a8d6 fix(d3d12): build with Windows SDK headers that lack the D3D12 sample-pattern names
D3D12_STANDARD_MULTISAMPLE_PATTERN and D3D12_CENTER_MULTISAMPLE_PATTERN
are only in d3d12.h from DirectX-Headers 1.613 (D3D12_SDK_VERSION 613)
on; older Windows SDK 10.0.26100 headers lack them, so gta6rt_d3d12_com
and d3d12_vulkan_device_test stop with C2065 under VS 2022. They are
enum members, so an #ifndef fallback can't detect them. Use the equal
DXGI_STANDARD/CENTER_MULTISAMPLE_QUALITY_PATTERN macros from
dxgicommon.h, which d3d12.h includes on every SDK.
2026-11-22 09:36:23 -06:00
eb35aed2e7 Merge origin/main into shader-309-wave64-lds-limit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:32:05 +01:00
d9f7ec4162 Merge upstream main
# Conflicts:
#	tools/fspx_unpack.py
2026-11-22 10:28:36 -05:00
6a16ac1436 FSPX lookup: a kind-0 state key next to the code key; ambiguous programs are refused (RT-99 review)
Review on #1911: two containers with the same kind-6 program and different kind-0 entries (32x1x1 and 64x1x1)
translate to different modules but got the same fspx_code_sha256, so both resolved to the same pipeline.

- tools/fspx_unpack.py writes the kind-0 entry as fspx/<name>.state; tools/shader_meta.py records its SHA-256 as
  fspx_state_sha256 next to fspx_code_sha256.
- make_game.py: entries with the same code and state keys must have identical modules, otherwise the FSPX step fails
  naming both programs and drops the index. The same code key with other state keys is allowed.
- runtime: a container or bare payload (kinds 0 and 6 present) matches the code key and then the state key; no match
  is E_INVALIDARG. A bare kind-6 program (slot 67, no kind 0) takes the code key's entries when their modules are
  identical, and is refused with E_INVALIDARG and an "ambiguous" log line when they differ.
- Tests: the review case in tests/test_fspx_shaders_stage.py, shader_library_test and d3d12_fspx_compute_test.
- docs/fspx.md: the two keys and the ambiguous case.

On 1.0.2.1 the 29 kind-6 programs are distinct, so nothing resolved wrongly before: 17 translated entries, 17
distinct code keys, 17 distinct (code, state) pairs, all 17 found from the container and from the bare program.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:28:07 -05:00
7d30d3fd83 D3D-238: accept HARDWARE_PROTECTED heaps, as the host does
A host run on an RTX 4070 SUPER and a UHD 770 (@CowBoYdu76) creates a
HARDWARE_PROTECTED default heap, though the D3D12_HEAP_FLAGS
documentation calls it unsupported. heap_desc_refusal no longer refuses
it; it moves from the refusal cases to compare_heap_neighbours and the
accepted list. ALLOW_DISPLAY stays refused, now confirmed on those hosts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:27:24 +01:00
352b9af158 d3d12: map the six narrow signed IA vertex formats
vertex_format() mapped the unsigned and float variants of R16, R8G8 and R8 but not R16_SNORM, R16_SINT, R8G8_SNORM, R8G8_SINT, R8_SNORM or R8_SINT, so a PSO whose input layout used one was refused with E_INVALIDARG. Add the six rows and cover them in d3d12_draw_test: the SNORM formats use the float VS, the SINT formats an integer-input VS declared ivec4. The test fails on the old table at line 157 (format 58) and passes with the rows, with no validation messages on an RTX 3070.
2026-11-22 07:27:16 -08:00
28ef599619 Runtime: pick the Vulkan GPU by the harnesses' rank (native over Dozen)
The runtime's standalone device (d3d12_vulkan_device.cpp) still took
"the first usable device, replaced by every later discrete GPU". #915
fixed that rule in the test harnesses because Mesa's Dozen (Microsoft
vendor 0x1414, "Microsoft Direct3D12 (<gpu>)") reports a discrete GPU, so
on a PC with the OpenCL/OpenGL/Vulkan Compatibility Pack the runtime
could run on the Vulkan-on-D3D12 wrapper while the tests used the native
driver. Even without Dozen, on a two-dGPU PC the runtime took the last
GPU and vk_test_device.h the first.

- runtime/src/vulkan_device_filter.h: vulkan_device_rank() (native over
  Microsoft's layers, then discrete > integrated > virtual > CPU), with
  the device type as an int so the header stays Vulkan-free.
- d3d12_vulkan_device.cpp: the first usable device of the highest rank.
- vk_device_pick.h: device_rank forwards to it (static_assert on the
  VkPhysicalDeviceType values).
- d3d12_indirect_rt_test, dxgi_swapchain_test, vk_image_fuzz,
  vk_sampler_test had the old loop and ignored LEONIDA_VK_DEVICE: they
  now filter and rank like the rest, and an unmatched filter fails
  instead of skipping.
- vulkan_device_filter_test: the rank order; docs/testing.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:27:09 +00:00
6c47d748b1 Merge remote-tracking branch 'origin/main' into d3d-238-createheap-validation 2026-11-22 16:26:16 +01:00
b17531d021 Support sparse tile mappings for reserved D3D12 buffers
Depends on D3D-16 (PR #286).
2026-11-22 12:24:19 -03:00
ea32ba2f8e d3d12: review fixes for the new formats
- UAV clears of A4B4G4R4: an R4G4B4A4_PACK16 layout row (red in bits
  12-15, alpha in 0-3), unit-checked in conversion_checks and cleared end
  to end where the layer reports a typed UAV (the driver's call: WARP has
  one, AMD's D3D12 driver doesn't).
- FORMAT_SUPPORT reports IA_VERTEX_BUFFER only for formats input layouts
  accept (vertex_format), not every format Vulkan can fetch: R8/R16
  SNORM/SINT (and R8G8 SNORM/SINT) have no input-layout mapping yet.
- new_format_round_trips: each render-target format is cleared to
  (-3, -0.4, 0.25, 7) on the layer and on the host and the bytes compared,
  which catches a mapping of the right size but the wrong numeric type
  (R16_SNORM as UNORM, R8_SINT as UINT); no value is an exact half step.
  The host is the Vulkan device's own adapter, as in
  compare_format_support, not the default one.
- A4B4G4R4 is skipped where the Vulkan driver can't sample
  R4G4B4A4_UNORM_PACK16 (Vulkan doesn't require it), by the driver's
  format properties rather than the layer's answers; B4G4R4A4 and
  B5G5R5A1 are never skipped.
- d3d12_copy_xfmt: D16_UNORM <-> R16_UINT and R16_SNORM copies, the new
  members of depth_colour_pair, against the host and WARP.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:23:58 +01:00
47f4cdc643 runtime: route LoadLibrary/GetProcAddress of bundled package DLLs through rt::Loader 2026-11-22 16:21:16 +01:00
569bd01d7e Runtime: blends into B8G8R8X8 targets read destination alpha 1 (D3D-240)
B8G8R8X8 has no alpha, and WARP and AMD's D3D12 driver blend into it with
destination alpha 1. Its Vulkan image is BGRA8, so the blend factors that
read destination alpha read the X byte instead. For B8G8R8X8 render
targets the PSO now turns DST_ALPHA into ONE, ONE_MINUS_DST_ALPHA into
ZERO and the colour SRC_ALPHA_SATURATE into ZERO, in the colour and alpha
factors alike.

d3d12_draw_test blends a full-screen pass into B8G8R8X8 and B8G8R8A8
targets cleared with alpha 0.25 through the five factors that read
destination alpha, and compares red, green and blue. The X byte is left
out: WARP writes 0 there after a draw and AMD the blended alpha, and no
view reads it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:20:23 -03:00
efeef30822 d3d12: select integer transparent black for UINT custom border fallback
- For samplers with custom border colours (BorderColor::table), retain is_int in the fallback path when VK_EXT_custom_border_color is unavailable.
- Select VK_BORDER_COLOR_INT_TRANSPARENT_BLACK for UINT custom borders and VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK for float custom borders, satisfying Vulkan input validation rules on integer views (reported by Vonsek, #760).
- In vulkan_sampler(), default to VK_BORDER_COLOR_INT_TRANSPARENT_BLACK when sampler.integer_border is set for table colours.
- Update d3d12_sampler2_test with a fallback device and vkCreateSampler interception to verify that VK_BORDER_COLOR_INT_TRANSPARENT_BLACK and VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK are requested as expected.

Tested on Windows 11, MSVC 2022 x64 (Ninja, RelWithDebInfo), NVIDIA GeForce RTX 2070 SUPER.
Clean-room verification suite passed with exit code 0.
Co-Authored-By: Antigravity <antigravity@google.com>
2026-11-22 16:14:57 +01:00
3e3d94f65c d3d12: custom sampler border colours on VK_EXT_custom_border_color (D3D-73)
- Implements custom float and UINT sampler border colours on VK_EXT_custom_border_color in runtime/shims/d3d12_vulkan_device.cpp.
- Maintains a device-wide border colour table of up to 4000 entries.
- Assigns table indices into S# BORDER_COLOR_PTR [11:0] (with BORDER_COLOR_TYPE = table), ensuring distinct custom colours produce distinct keys in the bindless descriptor hash table while identical colours reuse existing indices.
- Chains VkSamplerCustomBorderColorCreateInfoEXT with VK_BORDER_COLOR_FLOAT_CUSTOM_EXT / VK_BORDER_COLOR_INT_CUSTOM_EXT and format = VK_FORMAT_UNDEFINED when customBorderColorWithoutFormat is enabled. Falls back to transparent black with a diagnostic warning when the extension is absent.
- Enables VK_EXT_custom_border_color in standalone device creation and vk_test_device.h.
- Updates d3d12_sampler2_test to verify table index assignment, index reuse, S# distinction between float and UINT representations, and Vulkan sampler creation.
- Documents the architecture in docs/d3d12_vulkan.md.

Tested on Windows 11, MSVC 2022 x64 (Ninja, RelWithDebInfo), NVIDIA GeForce RTX 2070 SUPER, Driver 595.79.
Clean-room verification suite (python compileall, make_game.py CLI, 27/27 CTest, d3d12_vulkan_device_test, d3d12_sampler2_test, d3d12_descriptor_test) passed with exit code 0.

Item: D3D-73 (#634)
Co-Authored-By: Antigravity <antigravity@google.com>
2026-11-22 16:14:56 +01:00
09857dfa54 Validate DXGI flip-model swapchain sample descriptions 2026-11-22 19:08:35 +04:00
2b2effeacb runtime: answer non-OPTIONS CheckFeatureSupport queries (D3D-258) 2026-11-22 16:07:42 +01:00
3ba5205180 gameinput: implement IGameInput::CreateAggregateDevice and reading delegation 2026-11-22 20:37:22 +05:30
d6443b1524 Startup trace: never replace an existing file; write UTF-8 only
Review on #1756 (Vonsek):
- The trace is opened before the loader reads the image, so `wb` could
  truncate an input named by mistake (the image itself). open() now
  uses "x" mode and fails with EEXIST on an existing path; gta6rt says
  so and exits with 2.
- OutputDebugStringA text is in the ANSI code page. It is converted
  to UTF-8 before quoting, so a byte such as 0xE9 no longer breaks the
  JSON lines. Host module names now come from GetModuleFileNameW,
  converted to UTF-8, for the same reason.

startup_trace_test: an existing file is refused with EEXIST and its
bytes survive, the trace stays off; an ANSI debug string with 0xE9
appears as its UTF-8 form and the whole file is valid UTF-8.
2026-11-22 12:06:49 -03:00
2dca597bd9 Runtime: opt-in startup trace (gta6rt --trace FILE)
Writes one JSON object per line, flushed per event: module maps, TLS
callbacks, DllMain results, the first call of each unimplemented import
with its caller as module+RVA, OutputDebugString text, exceptions with
module+RVA and a short unwind, and the exit code. A vectored handler
records and returns EXCEPTION_CONTINUE_SEARCH, so behaviour is unchanged.
Off by default.

startup_trace_test builds a synthetic DLL image (no game data) and
checks each event kind.
2026-11-22 12:03:22 -03:00
7b48c194c0 Use Vulkan swapchain maintenance aliases supported by older headers 2026-11-22 19:00:41 +04:00
6531d9c696 fix(runtime): trace graphics descriptor setup
Show whether callers attempted to set graphics descriptor tables or shader-visible heaps before the first draw.
2026-11-22 15:59:03 +01:00
8fc8147bf3 docs+shims: fold in the measured Xbox ABI surface from sibling layers
Other Xbox Series compatibility-layer efforts have run the same package's
console DLLs, shader pack and retail titles. This folds their published
measurements into docs/d3d12_vulkan.md §7 — the CS root-argument packing, the
inline record opcodes, the mesh inputs, the OpenExistingHeapFromAddress UMA
recipe, 64 KiB physical pages, more command-list slot numbers and the console
export surface — each row paraphrased with its measurement basis noted.

The unimplemented-import classifier learns the console DLL names from that
surface (d3d12_xs!D3D12XboxCreateSyntheticDevice, xaudio2_9!XAudio2Create,
gameinput!GameInputCreate, dstorage_xs!DStorageGetFactory) so fail/stop
policies report E_NOTIMPL honestly instead of faking success; functions with
no measured return (xg_xs, AcpHal, D3D12XboxSetProcessDebugFlags) stay `other`.
Classification checks added to unimplemented_policy_test.

AI-assisted. Tested: test_i18n_index, test_docs_links, compileall. The
registry/test change is Windows-only C++ and was not compiled here.
2026-11-22 07:57:55 -07:00
d63fac7606 Merge branch 'main' into d3d-238-createheap-validation 2026-11-22 15:57:50 +01:00
0a488f6733 D3D-238: refuse ALLOW_DISPLAY and HARDWARE_PROTECTED, leave CreateHeap1 to #1846
heap_desc_refusal now also refuses D3D12_HEAP_FLAG_ALLOW_DISPLAY and
HARDWARE_PROTECTED, which the D3D12_HEAP_FLAGS documentation says
CreateHeap does not support (review on #1820). Both are host-comparison
cases in compare_invalid_arguments, awaiting a host run, and direct
refusal checks on the standalone device.

CreateHeap1, its heap1 test cases and the heap_create1 helper are
removed: #1846 implements CreateHeap1 over CreateHeap and inherits these
checks. The docs keep #1846's CreateHeap1 line untouched and describe
the CreateHeap checks under the heap bullet instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:56:23 +01:00
8cbf2c2f6c Runtime: MSAA PSOs take the standard sample pattern; draws check attachment sample counts
CreateGraphicsPipelineState refused every SampleDesc.Quality but 0. Native
D3D12 (RX 7800 XT, a Radeon iGPU and WARP) accepts 0,
D3D12_STANDARD_MULTISAMPLE_PATTERN and D3D12_CENTER_MULTISAMPLE_PATTERN and
refuses 1 (past NumQualityLevels). The standard pattern is Vulkan's standard
positions, so it is accepted; the centre pattern needs custom sample
locations and is refused with a log until those exist.

At replay every bound render target and depth target must have the PSO's
sample count (D3D12 leaves a mismatch undefined, Vulkan's dynamic rendering
forbids it), so a mismatched draw fails the list with invalid_subresource
instead of reaching the driver.

d3d12_msaa_draw_test (in ctest): 4x draws with a depth target, SampleMask 0x1
and ResolveSubresource; the quality rules; a 4x PSO into a 1x target.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:54:48 +01:00
4de870250e SHADER-309: keep compute workgroup memory under the limit
--wave64-emulate adds %x_buf (2L + 6W + 7 dwords) on top of the LDS
array, so a 64 KiB LDS made modules over maxComputeSharedMemorySize,
which spirv-val accepts and RADV dies on (#1721).

Translator: a 64 KiB hard cap (MAX_SHARED_BYTES, --max-shared-memory).
Over it, the pow2-rounded LDS array shrinks to the room left when the
program's need fits (indices wrap with OpUMod); otherwise the shader is
refused (Unsupported, with the byte counts). lds_bytes in index.json is
now the whole Workgroup total.

Runtime: the D3D12 shim's create_compute compares lds_bytes with the
device's maxComputeSharedMemorySize (32768 on AMD Windows and Intel)
and refuses the pipeline with a log line instead of creating it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:49:23 +01:00
a9929f9044 Merge pull request #1877 from Dominik 2026-11-22 09:49:01 -05:00
98dc77c4eb Merge pull request #1874 from Serrambi 2026-11-22 09:49:00 -05:00