Archived
ops: the tiled encode ops take their row count from the operands, not from M
The engine never hands a kernel the issued value of a ranged parameter: the oracle binds it to the matched band's bound, and ref_common.h's band_rows spells the rule out -- the parameter stays a ceiling where one is stated -- which is why every existing kernel derives its counts from its operands. vtile_plan/crop/join were the first to read M as the row count of the call, so the first real tiled encode refused on device: a 512 keyframe's 3 x 3 plan, issued under the band bound 33, tripped the wrapper's rows-of-y < M clause, which answered RAD_E_STRIDE -- and the strerror insisted, wrongly, that a non-contiguous operand was the problem. Crop and join carried the same latent bug: crop would have launched 33 blocks over a ~590k-row cut, and both would have refused every canvas under their bands' real bounds. All three tiers now count from the operands and treat the passed M as the ceiling it is -- y longer than the ceiling is refused, equality never demanded. The reference and host tiers take the count from geom through band_rows; the device wrappers take it from y's rows and pass that count in the kernel's M slot, which the kernels' own operand-row guards make safe. OPS.md says the rule once at the head of the tiled encoder section: an M written in a shape is an operand's row count, the ranged M argument a ceiling only. The host gates missed the bug precisely because they drove an exact M. ref_test's three vtile cases now pass the band's bound -- 33, 33 * 256 * 256, 320 * 320 -- and demand the same exact output, plus short-operand cases that must refuse E_SHAPE under the over-declared ceiling; r4d_selftest drives the same bounds on device. Verified: ref_test 264 cases, device vtile plan 4 / crop 8 / join 5 / gather 2 / stitch 8 all exact, full ctest 123/123; and the FL2VA render that used to die in tiled encode now runs its 25 steps with both keyframes visible in the decoded clip. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
fe311c5c80
commit
c463a0ab1b
6 files changed
+98
-40
No files matched your search
+18
-9
@@ -860,13 +860,17 @@ extern "C" int r4d_rad_vtile_plan(const RadArgs* a, RadStream s) {
|
||||
if (M <= 0 || tile <= 0 || overlap < 0 || overlap >= tile || ratio <= 0 ||
|
||||
r4d_numel(geom) < 3)
|
||||
return R4D_NO(RAD_E_SHAPE);
|
||||
/* The tile count comes from y: the engine binds the ranged parameter to the band's bound,
|
||||
* not to this call's rows (ref_common.h's `band_rows` rule), and r4d_rows_pitch already
|
||||
* read y narrowed to them. The parameter is a ceiling only. */
|
||||
long long ry = 0;
|
||||
const long long yl = r4d_rows_pitch(y, 22, &ry);
|
||||
if (yl < 0 || !r4d_contig(geom) || ry < M) return R4D_NO(RAD_E_STRIDE);
|
||||
const int64_t total = (int64_t)M * 22;
|
||||
if (yl < 0 || !r4d_contig(geom)) return R4D_NO(RAD_E_STRIDE);
|
||||
if (ry <= 0 || (M > 0 && ry > M)) return R4D_NO(RAD_E_SHAPE);
|
||||
const int64_t total = ry * 22;
|
||||
hipLaunchKernelGGL(vtile_plan_kernel, dim3(blocks_for(total)), dim3(kT), 0, (hipStream_t)s,
|
||||
(const int*)geom->data, (int*)y->data, (int)tile, (int)overlap, (int)ratio,
|
||||
(int)yl, M, ry);
|
||||
(int)yl, ry, ry);
|
||||
return st_of(hipGetLastError());
|
||||
}
|
||||
|
||||
@@ -881,13 +885,16 @@ extern "C" int r4d_rad_vtile_crop(const RadArgs* a, RadStream s) {
|
||||
r4d_numel(geom) < 3)
|
||||
return R4D_NO(RAD_E_SHAPE);
|
||||
long long rx = 0, ry = 0;
|
||||
/* y's rows are the tiles' pixel rows this call cuts; the ranged `M` is the band's bound, a
|
||||
* ceiling only (ref_common.h's `band_rows` rule). The kernel re-walks the tiles and stops at
|
||||
* their sum, so rows past it -- when the band overshoots the cut -- write nothing. */
|
||||
const long long xl = r4d_rows_pitch(x, 3, &rx), yl = r4d_rows_pitch(y, 3, &ry);
|
||||
if (xl < 0 || yl < 0 || !r4d_contig(geom)) return R4D_NO(RAD_E_STRIDE);
|
||||
if (ry < M) return R4D_NO(RAD_E_SHAPE);
|
||||
if (ry <= 0 || (M > 0 && ry > M)) return R4D_NO(RAD_E_SHAPE);
|
||||
#define R4D_VTC(T) \
|
||||
hipLaunchKernelGGL((vtile_crop_kernel<T>), dim3(blocks_for(M)), dim3(kT), 0, (hipStream_t)s, \
|
||||
hipLaunchKernelGGL((vtile_crop_kernel<T>), dim3(blocks_for(ry)), dim3(kT), 0, (hipStream_t)s, \
|
||||
(const T*)x->data, (const int*)geom->data, (T*)y->data, (int)tile, \
|
||||
(int)overlap, (int)ratio, (int)xl, (int)yl, M, rx, ry)
|
||||
(int)overlap, (int)ratio, (int)xl, (int)yl, ry, rx, ry)
|
||||
if (is_f32(x)) R4D_VTC(float);
|
||||
else R4D_VTC(uint16_t);
|
||||
#undef R4D_VTC
|
||||
@@ -904,13 +911,15 @@ extern "C" int r4d_rad_vtile_join(const RadArgs* a, RadStream s) {
|
||||
if (M <= 0 || tile <= 0 || overlap < 0 || overlap >= tile || n <= 0 || r4d_numel(geom) < 3)
|
||||
return R4D_NO(RAD_E_SHAPE);
|
||||
long long rx = 0, ry = 0;
|
||||
/* The canvas is y: its rows are the join's threads. The ranged `M` is the band's bound, a
|
||||
* ceiling only (ref_common.h's `band_rows` rule). */
|
||||
const long long xl = r4d_rows_pitch(x, n, &rx), yl = r4d_rows_pitch(y, n, &ry);
|
||||
if (xl < 0 || yl < 0 || !r4d_contig(geom)) return R4D_NO(RAD_E_STRIDE);
|
||||
if (ry < M) return R4D_NO(RAD_E_SHAPE);
|
||||
if (ry <= 0 || (M > 0 && ry > M)) return R4D_NO(RAD_E_SHAPE);
|
||||
#define R4D_VTJ(T) \
|
||||
hipLaunchKernelGGL((vtile_join_kernel<T>), dim3(blocks_for(M)), dim3(kT), 0, (hipStream_t)s, \
|
||||
hipLaunchKernelGGL((vtile_join_kernel<T>), dim3(blocks_for(ry)), dim3(kT), 0, (hipStream_t)s, \
|
||||
(const T*)x->data, (const int*)geom->data, (T*)y->data, (int)tile, \
|
||||
(int)overlap, (int)n, (int)xl, (int)yl, M, rx, ry)
|
||||
(int)overlap, (int)n, (int)xl, (int)yl, ry, rx, ry)
|
||||
if (is_f32(x)) R4D_VTJ(float);
|
||||
else R4D_VTJ(uint16_t);
|
||||
#undef R4D_VTJ
|
||||
|
||||
Reference in new issue
Block a user