c2d1e9790e
Closes the H.264 deblock QPU coverage matrix. Adds the 4 intra
(bS=4) variants — luma_v/h_intra + chroma_v/h_intra.
Algorithmically distinct from the bS<4 path:
- Per-side strong/weak filter selector
strong_p = (|p2-p0| < β) AND (|p0-q0| < (α>>2) + 2)
strong_q = (|q2-q0| < β) AND (|p0-q0| < (α>>2) + 2)
- Strong-p updates p0/p1/p2 with 5-/4-/3-tap blends (reads p3)
- Weak-p updates p0 only with (2*p1 + p0 + q1 + 2) >> 2
- Mirror for q-side; no tc0 (bS=4 hardcodes the strength)
- Chroma always weak, only p0/q0 updated (same as bS<4 chroma)
Per H.264 §8.3.2.3. Transcribed from PR #11's C reference
(tests/h264_intra_loop_filter_ref.c).
Shaders:
- v3d_h264deblock_luma_v_intra.comp (luma 16-cell + strong/weak)
- v3d_h264deblock_luma_h_intra.comp (transpose of luma_v_intra)
- v3d_h264deblock_chroma_v_intra.comp (8-cell, always weak)
- v3d_h264deblock_chroma_h_intra.comp (transpose of chroma_v_intra)
Dispatch wiring:
- 4 new pipeline pairs in daedalus_ctx
- dispatch_h264_deblock_luma_intra_qpu helper (parameterised by
orient_h for V vs H) — 2 wrappers
- chroma intra reuses the existing dispatch_h264_deblock_chroma_qpu
helper (same WG geometry as bS<4 chroma) — 2 wrappers
- DEFINE_INTRA_DISPATCH macro extended with qpu_fn parameter,
routes CPU/QPU per recipe table
- Recipe table flips DAEDALUS_KERNEL_H264_DEBLOCK_*_INTRA from CPU
to QPU
Verified on hertz:
$ ./build/test_api_h264 | grep intra
H.264 deblock luma v intra: 1024/1024 bytes bit-exact
H.264 deblock luma h intra: 1024/1024 bytes bit-exact
H.264 deblock chroma v intra: 256/256 bytes bit-exact
H.264 deblock chroma h intra: 256/256 bytes bit-exact
All 4 PASS first try. Strong/weak quad-tree selector + per-side
asymmetry would have surfaced any sign/shift/index mistake; passing
on all 4 (including the asymmetric writes-3-cells cases) means the
transcription from C is clean.
Deblock QPU coverage matrix — COMPLETE (8 of 8):
bS<4 (non-intra):
luma_v ✓ cycle 8
luma_h ✓ PR #28
chroma_v ✓ PR #29
chroma_h ✓ PR #29
bS=4 (intra, this PR):
luma_v ✓
luma_h ✓
chroma_v ✓
chroma_h ✓
The full H.264 8-bit 4:2:0 hot-path pixel-math layer is now on QPU
when daedalus is initialised with a QPU-capable context:
- IDCT 4x4 / 8x8 ✓
- All 8 deblock variants ✓
- All 30 qpel positions (15 put_ + 15 avg_) ✓
71 lines
2.7 KiB
Plaintext
71 lines
2.7 KiB
Plaintext
// daedalus-fourier — H.264 luma intra (bS=4) H deblock — V3D 7.1.
|
|
//
|
|
// Sibling of v3d_h264deblock_luma_v_intra.comp transposed to the
|
|
// horizontal axis: lane → row, reads pix[-4..+3] (cols) instead of
|
|
// pix[-4*stride..+3*stride] (rows). Same strong/weak filter
|
|
// selector + same write-back algebra.
|
|
//
|
|
// dst_off contract: (m.x % stride) ≥ 4 (kernel reads p3 at pix[-4]).
|
|
//
|
|
// License: BSD-2-Clause.
|
|
|
|
#version 450
|
|
#extension GL_EXT_shader_8bit_storage : require
|
|
#extension GL_EXT_shader_explicit_arithmetic_types : require
|
|
|
|
layout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in;
|
|
layout(binding = 0) readonly buffer Meta { uvec4 meta[]; } u_meta;
|
|
layout(binding = 1) buffer Dst { uint8_t dst[]; } u_dst;
|
|
layout(push_constant) uniform PC {
|
|
uint n_edges, dst_stride_u8, _p0, _p1;
|
|
} pc;
|
|
|
|
void main()
|
|
{
|
|
uint lane_in_wg = gl_GlobalInvocationID.x & 255u;
|
|
uint edge_in_wg = lane_in_wg >> 4;
|
|
uint row_in_edge = lane_in_wg & 15u;
|
|
uint edge_idx = gl_WorkGroupID.x * 16u + edge_in_wg;
|
|
if (edge_idx >= pc.n_edges) return;
|
|
|
|
uvec4 m = u_meta.meta[edge_idx];
|
|
uint stride = pc.dst_stride_u8;
|
|
uint dst_off = m.x + row_in_edge * stride;
|
|
int alpha = int(m.y & 0xffu);
|
|
int beta = int((m.y >> 8) & 0xffu);
|
|
if ((alpha | beta) == 0) return;
|
|
|
|
int p3 = int(u_dst.dst[dst_off - 4u]);
|
|
int p2 = int(u_dst.dst[dst_off - 3u]);
|
|
int p1 = int(u_dst.dst[dst_off - 2u]);
|
|
int p0 = int(u_dst.dst[dst_off - 1u]);
|
|
int q0 = int(u_dst.dst[dst_off ]);
|
|
int q1 = int(u_dst.dst[dst_off + 1u]);
|
|
int q2 = int(u_dst.dst[dst_off + 2u]);
|
|
int q3 = int(u_dst.dst[dst_off + 3u]);
|
|
|
|
if (abs(p0 - q0) >= alpha) return;
|
|
if (abs(p1 - p0) >= beta) return;
|
|
if (abs(q1 - q0) >= beta) return;
|
|
|
|
bool strong_common = abs(p0 - q0) < (alpha >> 2) + 2;
|
|
bool strong_p = strong_common && abs(p2 - p0) < beta;
|
|
bool strong_q = strong_common && abs(q2 - q0) < beta;
|
|
|
|
if (strong_p) {
|
|
u_dst.dst[dst_off - 1u] = uint8_t(clamp((p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4) >> 3, 0, 255));
|
|
u_dst.dst[dst_off - 2u] = uint8_t(clamp((p2 + p1 + p0 + q0 + 2) >> 2, 0, 255));
|
|
u_dst.dst[dst_off - 3u] = uint8_t(clamp((2*p3 + 3*p2 + p1 + p0 + q0 + 4) >> 3, 0, 255));
|
|
} else {
|
|
u_dst.dst[dst_off - 1u] = uint8_t(clamp((2*p1 + p0 + q1 + 2) >> 2, 0, 255));
|
|
}
|
|
|
|
if (strong_q) {
|
|
u_dst.dst[dst_off ] = uint8_t(clamp((q2 + 2*q1 + 2*q0 + 2*p0 + p1 + 4) >> 3, 0, 255));
|
|
u_dst.dst[dst_off + 1u] = uint8_t(clamp((q2 + q1 + q0 + p0 + 2) >> 2, 0, 255));
|
|
u_dst.dst[dst_off + 2u] = uint8_t(clamp((2*q3 + 3*q2 + q1 + q0 + p0 + 4) >> 3, 0, 255));
|
|
} else {
|
|
u_dst.dst[dst_off ] = uint8_t(clamp((2*q1 + q0 + p1 + 2) >> 2, 0, 255));
|
|
}
|
|
}
|