Commit Graph

114 Commits

Author SHA1 Message Date
e80485e24e Merge main into d3d-61-b4g4r4a4
The only conflict: block_format's two-byte list, where main added
R5G6B5_UNORM_PACK16 (#587) next to this PR's A4R4G4B4_UNORM_PACK16. Both kept.
2026-11-22 02:05:52 +00:00
9b70afedb8 Runtime: B4G4R4A4_UNORM textures (D3D-61)
CreateCommittedResource refused DXGI_FORMAT_B4G4R4A4_UNORM. It now maps
to VK_FORMAT_A4R4G4B4_UNORM_PACK16: DXGI names channels from the low bits
up and Vulkan from the high bits down, so both have B in bits 0-3 and A
in 12-15. Vulkan 1.3 requires sampling it. Copies use two-byte texels,
and the shader-resource view is a 4_4_4_4_UNORM T#, which the GFX10
table already had.

d3d12_descriptor_test uploads an 8x8 texture with a different nibble in
every channel of every texel, checks the footprint (two-byte rows), and
samples it through set 0: all 64 texels match, each nibble n read as
n * 17.
2026-11-22 02:00:15 +00:00
69e3be8bc5 Runtime: depth-plane shader-resource views of depth-stencil textures
R24_UNORM_X8_TYPELESS (D24S8) and R32_FLOAT_X8X24_TYPELESS (D32S8) views
were refused ("view format not supported for this texture: 46") and wrote
a null descriptor, so shadow maps and depth reads of these textures found
nothing. They now write a T# of the texture's own depth format
(8_24_UNORM, X24_8_32_FLOAT) with the depth in R, which set 0 views
through the depth aspect.

d3d12_descriptor_test checks both formats next to their stencil views:
same address, the depth format's code, R from X.

Depends on: #668
2026-11-22 01:49:06 +00:00
df9039e64d feat(runtime): bind single-sampled 3D texture SRVs
Volume depth belongs in the T# depth field, while its Vulkan view has a single array layer. Route matching descriptors through the existing 3D binding so a shader can select W slices and use a view-relative mip.
2026-11-22 02:45:57 +01:00
ed7e1ead05 D3D-61: keep alpha-only texture sampling distinct from R8 2026-11-21 22:44:35 -03:00
dd201e794e Runtime: shader-resource views of the stencil plane (D3D-75)
PlaneSlice 1 of a depth-stencil texture, viewed as X24_TYPELESS_G8_UINT
or X32_TYPELESS_G8X24_UINT, now writes an 8_UINT T# (the format of the
console's separate stencil surface) at the texture's address, with the
eight bits in G and R, B, A as 0, 0, 1, as D3D12 returns them. set 0
views it in the image's own format with the stencil aspect.

A plane past 1, plane 1 of a texture without stencil, or another view
format stays a null descriptor with a log. d3d12_descriptor_test decodes
both stencil formats and checks the refusals.
2026-11-22 01:44:24 +00:00
0175e92e61 Merge the rebased RGB9E5 dependency and preserve border sampler checks 2026-11-21 22:23:59 -03:00
f5f4cb03f7 Merge remote-tracking branch 'upstream/main' into codex/rgb9e5-texture
# Conflicts:
#	runtime/shims/d3d12_vulkan_device.cpp
#	runtime/src/vulkan_replay.h
#	runtime/test/d3d12_descriptor_test.cpp
2026-11-22 02:20:43 +01:00
008560e49d Support B5G5R5A1 sampled textures and two-byte footprints 2026-11-21 22:11:47 -03:00
b3e71d7a4d runtime: UINT border colours use VK_BORDER_COLOR_INT_* (#538 review)
A UINT opaque-white border read back as 0 (Vonsek, on an RTX 5080). The S# has
no integer border types, since the hardware reads them by the image's format.
So bind_sampler gave Vulkan VK_BORDER_COLOR_FLOAT_*, which an integer image
reads as 0. The float and UINT samplers also shared one S# key and so one
VkSampler.

An integer border is now marked in the S#: BORDER_COLOR_PTR = 0x800
(gfx10::kIntegerBorderPtr), a field the hardware reads only for table colours.
That gives it its own key, and vulkan_sampler picks VK_BORDER_COLOR_INT_*.

d3d12_descriptor_test runs Vonsek's case: an R8G8B8A8_UINT texture sampled past
its edge through UINT black and white border samplers reads 0 and 1, and a
float white border reads 255. The case fails with the float enums on an RTX
4090. gfx10_descriptors_test and d3d12_sampler2_test check the mark.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 01:03:36 +00:00
3973ce8c20 feat(runtime): support sampled RGB9E5 textures
Map the shared-exponent format through resource creation and buffer-image copies so shaders can resolve its existing GFX10 view. Check the sampled channels and compare the mip-array footprints with the host runtime.
2026-11-22 01:47:40 +01:00
438e144270 Runtime: build with MSVC; the descriptor test shows a missed sampler lookup
Two findings from the review of #328, on MSVC 19.44 and an RTX 5080.

- bind_image did not compile with MSVC (C2397): the view's aspect, picked
  between two VkImageAspectFlagBits values, went into a VkImageAspectFlags
  field in braces. MSVC's enums are ints, so that is a narrowing
  conversion there; GCC and clang give the enum an unsigned type and accept
  it. The value is cast now.
- d3d12_descriptor_test passed with the sampler index forced to 0, because
  its point, clamping sampler and the fallback sampler read the same
  texels. The test's sampler now wraps in U and the shader samples one
  tile to the right: the right sampler gives the texture, the fallback its
  right edge. With the index forced to 0 the test fails (texel 0 reads
  224, 0, 135, 255 instead of 0, 0, 128, 255).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 18:28:13 -05:00
bc14565c45 Runtime: texture views and samplers go into the bindless set (M2, the device's part)
The device now keeps set 0 of the translated shaders and puts into it what
views and samplers name. No pipeline binds the set yet: that comes with
the compute path. Until then rt::d3d12::bindless_set / bindless_set_layout
hand it out.

- Device: CreateShaderResourceView and CreateUnorderedAccessView of
  textures write a T# into the slot, CreateSampler an S#
  (gfx10_descriptors.h); each makes sure set 0 has the view or sampler and
  the hash table has the key. The key is the descriptor's bytes, so a
  copied descriptor needs nothing more. A view that cannot be shown (a
  volume, a multisampled texture, the stencil plane, a range past the
  texture) leaves a null descriptor, which finds the fallback. A texture
  is named by an address of its own above 4 GiB that nothing dereferences;
  its keys are erased and its indices freed when it is destroyed.
- VulkanDeviceInfo::bindless says the Vulkan device has the features; the
  standalone device and the test helper enable them where the GPU has
  them, with samplerAnisotropy and samplerMirrorClampToEdge.
- Every ExecuteCommandLists flushes the set before its commands are
  written (VulkanContext::set_bindless_prepare).
- Layouts: a bindless descriptor has one image layout, but D3D12 samples a
  texture both in a shader-resource state and while promoted from COMMON
  (GENERAL here). With the set, a texture's shader-resource states use
  GENERAL too (ResourceBinding::sampled_in_general). This follows from the
  Vulkan rule for descriptor layouts; no test can see it broken, since the
  validation layer does not follow dynamic indices into runtime arrays.

Not done, and listed in docs/d3d12_vulkan.md: buffer and constant-buffer
views, 1D/3D/multisampled and stencil views, descriptors the game writes
itself, static samplers and shaders' literal S#s, and holding back a flush
that moves table entries while earlier command lists still run.

Test: d3d12_descriptor_test, through the Xbox-ABI proxy. It decodes what
the slots hold (a view of an uploaded 8x8 texture, a sampler, a BGRA cube
view with a component mapping, an unordered-access view, null
descriptors). Then a compute shader (test/glsl/cs_sample.comp, compiled
with glslangValidator where it is found) is handed a slot's T# and the
sampler's S#, looks them up in the hash table as a translated shader does
and samples; the test creates that pipeline in Vulkan and binds the
device's set. It reads the texture through the view's own slot and
through a copy of it, and gets the fallback from a slot of bytes no view
was made for and, once the texture is destroyed, from the view's own
bytes. Without the table insert, or without the removal at destruction,
the test fails. The test no longer compiles d3d12_xs_device.cpp itself:
the COM library has it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 18:28:13 -05:00
d5eabdad6a Runtime: CopyDescriptors and CopyDescriptorsSimple on the Vulkan device
A descriptor is the bytes of its heap slot (a TargetView in RTV and DSV
heaps, otherwise what the shader loads), so both are byte copies.
CopyDescriptors walks the destination and source range lists together,
one descriptor at a time; null size arrays mean one descriptor per range,
and whichever side runs out first ends the copy.

Test: d3d12_descriptor_test, through the Xbox-ABI proxy, checks the slots'
bytes for one run, range lists of different shapes on each side, null
size arrays, a destination longer than its source, and null arguments.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 16:56:56 -05:00