Commit Graph

2 Commits

Author SHA1 Message Date
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
f43bead284 Runtime: GFX10 T#, S# and V# descriptors (encode, decode, Vulkan mappings)
docs/d3d12_vulkan.md section 5.3 asks for a C++ decoder of the structures the
shaders read from descriptor heaps, and section 3.4 for the layer to write them
in Create*View and CreateSampler. runtime/src/gfx10_descriptors.h is that
piece, as a header with no Windows dependency; nothing uses it yet.

- T# (image, 8 dwords), S# (sampler, 4) and V# (buffer, 4): encode from and
  decode to plain structs. Field positions are Mesa's register database
  (src/amd/registers/gfx10-rsrc.json, the gfx103 types), enum values its
  gfx6.json, and what goes where follows ac_descriptors.c and radv. They agree
  with what the translator reads: T# FORMAT at word 1 bits 28:20, the V# base,
  stride, NUM_RECORDS, FORMAT and DST_SEL.
- Only what a Vulkan view or sampler needs is encoded; tiling, compression
  metadata and tuning fields are written as zero and ignored when decoding.
- decode refuses dwords whose TYPE is not an image's (so a V# in a 32-byte heap
  slot is told apart), a reserved DST_SEL, and ranges that end before they
  start.
- Format table: GFX10_FORMAT code <-> VkFormat with each format's channel
  order as a DST_SEL (BGRA8 is 8_8_8_8 read as Z, Y, X, W), the view format for
  a T# on an image, DST_SEL -> VkComponentMapping, S# -> VkSamplerCreateInfo,
  T# type -> VkImageViewType (a cube is a 2D array, as the translator samples
  it).

Tests: gfx10_descriptors_test (ctest, Vulkan headers only): every field alone
at its bit position, round trips, refusals, the T#s cs_imgstore.asm builds,
the V# as the translator reads it, sampler words as radv writes them, the
format table and the mappings. tests/test_gfx10_descriptors.py reads the
table out of the header and checks each code's name against
tools/gfx10_formats.json and each Vulkan format's layout against that name.
Moving FORMAT by one bit, or giving a row another code, fails them.

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