Commit Graph

10 Commits

Author SHA1 Message Date
d3f4bb0b56 Merge pull request #3547 from FIocker 2026-11-22 17:02:38 -05:00
fc51440f44 gfx10_descriptors: an unnormalized S# clamps U and V and uses one filter on Vulkan
vulkan_sampler() kept the S#'s address modes and filters when FORCE_UNNORMALIZED is set.
Vulkan requires unnormalizedCoordinates samplers to use CLAMP_TO_EDGE or CLAMP_TO_BORDER on U
and V (VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075) and equal min and mag filters
(-01072). WRAP is the S#'s default mode (word 0 = 0), so any S# with FORCE_UNNORMALIZED and
no explicit clamp produced an invalid VkSamplerCreateInfo.

U and V now clamp to the edge (a border mode stays the border); W is left as decoded; the
minification filter follows the magnification filter. gfx10_descriptors_test checks both cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:52:45 +01:00
90927ab35b Runtime: reject non-depth colour SRV formats on depth textures
Creating an SRV of a depth texture (D16_UNORM/R16_TYPELESS or D32_FLOAT/R32_TYPELESS) with a colour format (e.g. R16_FLOAT, R16_SNORM, R16_UINT, R16_SINT, R32_UINT, R32_SINT) previously produced a colour-format VkImageView with VK_IMAGE_ASPECT_DEPTH_BIT, violating VUID-VkImageViewCreateInfo-image-01762. Tighten vulkan_view_format(), image_descriptor() and bind_image() so depth/stencil textures only accept their own family's depth/stencil SRV formats and colour textures reject depth/stencil view formats. Adds exhaustive unit tests and GPU + Vulkan validation tests.
2026-11-22 16:56:36 +01:00
d7e1857c5d Merge origin/main into d3d90-castable-placed (resolve #1083 conflicts)
Both sides extended the same spots: the PR's castable-format flag and main's
R9G9B9E5-as-R32_UINT view emulation meet in bind_image (two extra defaulted
parameters), image_descriptor's view format (resource_format + castable list),
create_texture (TextureCreateInfo carries the VkImageFormatListCreateInfo the
castable list fills) and the device init (arena creation plus main's predication
configuration). Main's hardened CopyBuffer preparation and predicate capture
keep the PR's arena-buffer offsets; the PR's old emit-side offset math is
superseded by main's prepare-side buffer_offset handling.
2026-11-22 03:00:14 -08:00
cdc9ab3735 fix(runtime): respect the device limit for sampler LOD bias
Literal GFX10 samplers can encode bias from -32 to +31. A decoded +31 exceeded the Vulkan sampler limit on both tested devices at registration. Bound the native bias while retaining the original S# for shader lookup.
2026-11-22 09:43:56 +01:00
2933767eac Merge origin/main into d3d90-castable-placed (resolve #1083 conflicts)
Keep-both resolutions per #313's conflict analysis: main's ExecuteIndirect /
acceleration-structure / debug-marker / depth24 / node-mask features alongside
the stack's arena, compute and draw paths. Main's indirect and AS offsets gain
the arena's buffer_offset / heap_base compensation; AS resources on default
heaps get their GENERIC structure over the arena range. Reset clears
stencil_ref_set_ next to reset_state, and OMSetStencilRef sets it. README takes
main's (the crypto-token lines stay deleted).
2026-11-21 23:23:18 -08:00
01c0a56485 d3d12: accept castable formats on committed textures
Keep the creation-time castable list on the resource, reject an SRV format
that is neither the resource format nor listed, and allow listed same-size
cross-family casts such as R8G8B8A8_UINT to R32_UINT.
2026-11-21 21:56:17 -08:00
fac8b022d5 fix: preserve NEVER comparison samplers in set 0
The hardware depth function is zero for both a regular sampler and a NEVER comparison. Give layer-created NEVER comparisons a separate descriptor key so Vulkan binds a comparison-enabled sampler.
2026-11-22 04:39:05 +01: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
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