feat(d3d12_x): create Vulkan image views and samplers from D3D12 view and sampler descriptions #50

Manually merged
github merged 1 commit from gh-pr/50/head into gh-pr/50/base 2026-11-26 19:16:02 +00:00
Owner

@⁠Dark3581 on GitHub · 2026-11-22 21:43 UTC · original
Dark3581:feat/views-samplers → main · +1017 −6 · 9 files · 1 commits · merged 2026-11-22 21:47 UTC

What

  • resources/ViewDesc.cpp: ShaderResourceView, UnorderedAccessView, RenderTargetView and DepthStencilView turn a texture's view description (or none, for the default view) into a VkImageViewCreateInfo:
    • view types for every texture dimension, cube and cube array views of cube-compatible textures, 2D array views of a 3D texture's slices for render targets;
    • mip and array ranges, with -1 meaning the rest, checked against the texture;
    • Shader4ComponentMapping decoded into a swizzle (components and forced 0 or 1), and alpha read as 1 for B8G8R8X8 views;
    • a view format has to be in the texture's DXGI format family, and a different format needs a typeless texture; depth textures keep their depth format and the view format selects the depth or stencil aspect (R32_FLOAT_X8X24_TYPELESS depth, X32_TYPELESS_G8X24_UINT stencil with plane slice 1);
    • each view kind needs the matching resource flag.
  • TranslateSampler: filters (point, linear, anisotropic up to 16), comparison samplers, min and max reduction, the five address modes, the three preset border colors, the mip LOD bias and the LOD range (D3D12_FLOAT32_MAX as no clamp).
  • Refused with an error naming the cause: buffer views, minimum LOD clamps, other plane slices, UAVs of part of a 3D texture's depth, other border colors, bad mappings, ranges outside the texture, mismatched dimensions and unknown values.
  • The device enables imageCubeArray, samplerAnisotropy, samplerFilterMinmax and samplerMirrorClampToEdge when offered; views and samplers record what they need.
  • The README and the architecture page list views and samplers.

How these views relate to the console descriptor words a title writes into its descriptor heaps is not known yet; the debt fragment says so.

Tested

Windows 10, RTX 3070 Ti (driver 621.14), Khronos validation layer.

  • pso_probe views-selftest: component mappings (identity, forced values, invalid), 17 view cases translated and 12 checked field by field, 21 view refusals, 5 samplers checked field by field and 6 sampler refusals. Writing it found that the default shader resource view of a single 2D texture filled the array member of the union (its array size read as a minimum LOD clamp); fixed.
  • pso_probe views-gpu --validate: the 17 views on real images (bound to memory) and the 5 samplers: 22 created, 0 validation errors. Both run in the pipeline_state test.
  • MinGW ctest: 66 of 66. The d3d12_x targets also build with MSVC 2022 (which caught a numeric_limits<...>::max() hit by the <windows.h> macro; fixed). python tools/check_conventions.py and debt_fold.py --check: ok.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • python tools/check_conventions.py passes (no comments in code, one declaration per export, Conventional Commit subjects)
  • Unimplemented paths stop (AbxNotImplemented / AbxUnsupported); silent stubs are listed under Silent stubs through a debt fragment
  • Known gaps added, changed or removed through docs/dev/debt/changes/<branch>.md
  • Generic behaviour, not specific to one title
  • No game files, keys, notes or logs added to the repository
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • Source of behaviour: public D3D12 view, sampler and DXGI format documentation, Vulkan 1.3 specification
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-22 21:43 UTC · [original](https://github.com/Dark3581/AnyBox/pull/50) `Dark3581:feat/views-samplers` → `main` · +1017 −6 · 9 files · 1 commits · merged 2026-11-22 21:47 UTC ### What - **`resources/ViewDesc.cpp`**: `ShaderResourceView`, `UnorderedAccessView`, `RenderTargetView` and `DepthStencilView` turn a texture's view description (or none, for the default view) into a `VkImageViewCreateInfo`: - view types for every texture dimension, cube and cube array views of cube-compatible textures, 2D array views of a 3D texture's slices for render targets; - mip and array ranges, with `-1` meaning the rest, checked against the texture; - `Shader4ComponentMapping` decoded into a swizzle (components and forced 0 or 1), and alpha read as 1 for `B8G8R8X8` views; - a view format has to be in the texture's DXGI format family, and a different format needs a typeless texture; depth textures keep their depth format and the view format selects the depth or stencil aspect (`R32_FLOAT_X8X24_TYPELESS` depth, `X32_TYPELESS_G8X24_UINT` stencil with plane slice 1); - each view kind needs the matching resource flag. - **`TranslateSampler`**: filters (point, linear, anisotropic up to 16), comparison samplers, min and max reduction, the five address modes, the three preset border colors, the mip LOD bias and the LOD range (`D3D12_FLOAT32_MAX` as no clamp). - Refused with an error naming the cause: buffer views, minimum LOD clamps, other plane slices, UAVs of part of a 3D texture's depth, other border colors, bad mappings, ranges outside the texture, mismatched dimensions and unknown values. - The device enables `imageCubeArray`, `samplerAnisotropy`, `samplerFilterMinmax` and `samplerMirrorClampToEdge` when offered; views and samplers record what they need. - The README and the architecture page list views and samplers. How these views relate to the console descriptor words a title writes into its descriptor heaps is not known yet; the debt fragment says so. ### Tested Windows 10, RTX 3070 Ti (driver 621.14), Khronos validation layer. - `pso_probe views-selftest`: component mappings (identity, forced values, invalid), 17 view cases translated and 12 checked field by field, 21 view refusals, 5 samplers checked field by field and 6 sampler refusals. Writing it found that the default shader resource view of a single 2D texture filled the array member of the union (its array size read as a minimum LOD clamp); fixed. - `pso_probe views-gpu --validate`: the 17 views on real images (bound to memory) and the 5 samplers: 22 created, 0 validation errors. Both run in the `pipeline_state` test. - MinGW `ctest`: 66 of 66. The `d3d12_x` targets also build with MSVC 2022 (which caught a `numeric_limits<...>::max()` hit by the `<windows.h>` macro; fixed). `python tools/check_conventions.py` and `debt_fold.py --check`: ok. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] `python tools/check_conventions.py` passes (no comments in code, one declaration per export, Conventional Commit subjects) - [x] Unimplemented paths stop (`AbxNotImplemented` / `AbxUnsupported`); silent stubs are listed under Silent stubs through a debt fragment - [x] Known gaps added, changed or removed through `docs/dev/debt/changes/<branch>.md` - [x] Generic behaviour, not specific to one title - [x] No game files, keys, notes or logs added to the repository - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] Source of behaviour: public D3D12 view, sampler and DXGI format documentation, Vulkan 1.3 specification - [x] AI-assisted: yes
ViewDesc turns shader resource, unordered access, render target and depth-stencil view descriptions of textures into VkImageViewCreateInfo: view type, mip and array ranges (-1 meaning the rest), the four-component mapping, the depth or stencil aspect of depth textures chosen by the view format, alpha read as 1 for BGRX, and the rule that a view format must be in the texture's format family. Sampler descriptions become VkSamplerCreateInfo with filters, anisotropy, comparison, min and max reduction, address modes, the three preset border colors and the LOD range. The device enables the cube array, anisotropy, min-max and mirror-once features it offers; pso_probe gains a self test and a GPU test that creates 17 views and 5 samplers under the validation layer.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:16:00 +00:00
github manually merged commit 612ac6ead4 into gh-pr/50/base 2026-11-26 19:16:02 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.