diff options
| author | OreoFR <29048345+OreoFR@users.noreply.github.com> | 2026-11-25 09:02:38 +0100 |
|---|---|---|
| committer | OreoFR <29048345+OreoFR@users.noreply.github.com> | 2026-11-25 09:02:38 +0100 |
| commit | 4e7b764dbc04fbd5343fb6c99224a8b0bec9ae9c (patch) | |
| tree | 01ea1a85724da251036ff3767e131d7d7914d618 /runtime/src | |
| parent | 2f44380590e9471cb44b15818ad2c2c422a2af21 (diff) | |
d3d12_xs: integer render targets keep blending off in slot 57 native PSOs (RT-SLOT57-BLEND-STATE)
A library pipeline enables MAX on an R8_UINT target; the colour block bypasses
blending there, and D3D12 refuses the PSO.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src')
| -rw-r--r-- | runtime/src/native_pso.h | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/runtime/src/native_pso.h b/runtime/src/native_pso.h index 37460a21e..abe2c52e1 100644 --- a/runtime/src/native_pso.h +++ b/runtime/src/native_pso.h | |||
| @@ -242,12 +242,28 @@ inline std::optional<TargetBlend> d3d12_target_blend(std::uint32_t cb_blend, std | |||
| 242 | return t; | 242 | return t; |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | // A DXGI_FORMAT with UINT or SINT channels. The colour block does not blend those (RDNA2 bypasses blending for integer | ||
| 246 | // targets), and D3D12 refuses a PSO that enables blending on one. | ||
| 247 | inline bool dxgi_integer_format(std::uint32_t f) { | ||
| 248 | switch (f) { | ||
| 249 | case 3: case 4: case 7: case 8: case 12: case 14: case 17: case 18: case 25: case 30: case 32: case 36: | ||
| 250 | case 38: case 42: case 43: case 50: case 52: case 57: case 59: case 62: case 64: | ||
| 251 | return true; | ||
| 252 | default: | ||
| 253 | return false; | ||
| 254 | } | ||
| 255 | } | ||
| 256 | |||
| 245 | // The targets 0..count-1 of `r` in D3D12 terms, or empty when one of them cannot be expressed: the pipeline then keeps | 257 | // The targets 0..count-1 of `r` in D3D12 terms, or empty when one of them cannot be expressed: the pipeline then keeps |
| 246 | // the defaults (blending off, every component written) for all of its targets, as before blob A was read. | 258 | // the defaults (blending off, every component written) for all of its targets, as before blob A was read. A target |
| 247 | inline std::optional<std::array<TargetBlend, 8>> d3d12_blend(const BlendRegisters& r, unsigned count) { | 259 | // with an integer format (`formats`, DXGI values) keeps its write mask and has blending off, as on the console. |
| 260 | inline std::optional<std::array<TargetBlend, 8>> d3d12_blend(const BlendRegisters& r, unsigned count, | ||
| 261 | const std::array<std::uint8_t, 8>& formats = {}) { | ||
| 248 | std::array<TargetBlend, 8> out{}; | 262 | std::array<TargetBlend, 8> out{}; |
| 249 | for (unsigned i = 0; i < count && i < out.size(); ++i) { | 263 | for (unsigned i = 0; i < count && i < out.size(); ++i) { |
| 250 | const auto t = d3d12_target_blend(r.blend[i], r.target_mask >> (4 * i)); | 264 | const std::uint32_t mask = r.target_mask >> (4 * i); |
| 265 | const auto t = dxgi_integer_format(formats[i]) ? d3d12_target_blend(r.blend[i] & ~(1u << 30), mask) | ||
| 266 | : d3d12_target_blend(r.blend[i], mask); | ||
| 251 | if (!t) return std::nullopt; | 267 | if (!t) return std::nullopt; |
| 252 | out[i] = *t; | 268 | out[i] = *t; |
| 253 | } | 269 | } |