microsoft / microsoft/DirectXShaderCompiler

[HLSL] LinAlg HLK: Template the CPU oracle end to end

Open
#8,727 0 comments 0 reactions 1 assignee View on GitHub

@JoeCitizen is already working on this.

Since Aug 6, 2026.

Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Goal

Remove the untyped layer from the LinAlg CPU oracle in LinAlgTests.cpp so the component type is carried in the type system rather than switched on at runtime through ComponentType.

Why

The oracle currently has two parallel surfaces: templated helpers such as writeTypedMatrixBuffer<T> and decodeTypedMatrixBuffer<T>, and untyped wrappers that dispatch to them on a ComponentType value. The untyped layer exists only to bridge host code that has a runtime component type, and it costs a std::variant payload in TypedMatrix, a dispatch per entry point, and a class of failure — a mismatch between the variant alternative and the declared ComponentType — that a templated design cannot express at all.

Both reviewers of #8666 asked for this independently: Damyan Pepper at L109 and Ashley Coleman at L537. The surrounding harness is already moving this way — MatrixParams::CompType (#8285) is the typed precedent.

Required work
  • Establish whether the runtime-typed entry points are genuinely needed, or whether the callers can be templated too. Prefer templating the callers.
  • Where a runtime type genuinely must be dispatched, confine it to a single narrow boundary rather than duplicating it per entry point.
  • Reduce or remove the std::variant in TypedMatrix if the templating makes it redundant.
  • Keep the existing exact-comparison semantics unchanged; this is a restructuring, not a behaviour change.
Acceptance criteria
  • No ComponentType switch remains in the oracle's write, decode, transpose or verify paths.
  • LinAlgCPUOracleTests passes unchanged.
  • LinAlg::DxilConf_SM610_LinAlg::* result is identical to the pre-change baseline on the same runtime, test for test rather than by totals.
  • The variant-versus-ComponentType mismatch case is either impossible by construction or has an explicit single point of validation.
Blocked on

The current LinAlg HLK PR stack landing. This restructures the same file that every stack item builds on, so starting it earlier would force a re-parent of the whole stack for no behaviour change.

Public references
  • Proposal 0035 (hlsl-specs), Linear Algebra matrix operations.
  • #8285, which introduced MatrixParams::CompType.
  • Review threads on #8666 at L109 and L537.
Out of scope
  • Any change to which cases are covered, or to expected values.
  • The checked-arithmetic redesign (tracked separately).
  • Tolerance or ULP comparison modes (tracked separately).

Assisted-by: GitHub Copilot

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.