disablePitchPadding in NvBufSurfaceAllocateParams has no effect on JetPack 7 / L4T R39.2.1 (worked on R36.4.3)

A note before I start

I am a Japanese developer and my English is not strong. I wrote the original text in Japanese and used a generative AI to translate it into English, so the wording you see here is machine-assisted. The content is entirely mine and I stand behind it. Every number in this post is measured on my own boards.

I have three Jetson Orin Nano Super boards and I use them for a range of work. Any help would be much appreciated.

Summary

On Jetson Linux R36.4.3, NvBufSurfaceAllocate with disablePitchPadding = true returns a tight pitch (pitch == width for GRAY8). On Jetson Linux R39.2.1 the same call on the same board returns a pitch rounded up to a 256-byte boundary, and the flag makes no difference at all (true and false produce identical results).

The header documentation is unchanged between the two releases and still states that the pitch will be “width times bytes per pixel”.

Is this an intentional behavior change on R39.x, or a regression? If it is intentional, is there a supported way to obtain a tight-pitch, host-mappable NvBufSurface on R39.x?

Why this matters for us

We capture 8-bit Bayer frames at 227 fps from a Basler USB3 Vision camera. We allocate NVBUF_MEM_CUDA_PINNED surfaces with disablePitchPadding = true and hand the mapped host pointer straight to the Basler SDK’s IBufferFactory, so the camera writes directly into the surface with no cudaMemcpy2D. That zero-copy path depends on pitch == width, because the Basler SDK writes tightly packed rows. On R39.2.1 the pitch is 1536 for width 1440, so the direct-write path is no longer possible and we have to add a per-frame row-by-row copy.

Hardware

Both boards are the same model:

NVIDIA Jetson Orin Nano Engineering Reference Developer Kit Super

Software

Board A Board B
/etc/nv_tegra_release R36 (release), REVISION: 4.3, GCID 38968081 R39 (release), REVISION: 2.1, GCID 46758480
nvidia-l4t-multimedia-utils 36.4.3-20250107174145 39.2.1-20260806224157
DeepStream 7.1.0-1 9.1.0-1
TensorRT 10.3.0.30-1+cuda12.5 10.16.2.10-1+cuda13.2
Kernel R36.4.3 stock 6.8.12-1021-tegra

libnvbufsurface.so.1.0.0 is provided by nvidia-l4t-multimedia-utils on both boards (verified with dpkg -S), so this is an L4T-level difference rather than a DeepStream one.

Reproducer

/* build: g++ -O0 -o probe_pitch probe_pitch.c \
 *   -I/opt/nvidia/deepstream/deepstream/sources/includes \
 *   -L/opt/nvidia/deepstream/deepstream/lib -lnvbufsurface \
 *   -Wl,-rpath,/opt/nvidia/deepstream/deepstream/lib
 */
#include <nvbufsurface.h>
#include <stdio.h>
#include <string.h>

static void probe(NvBufSurfaceMemType mem, bool disable, unsigned w, unsigned h) {
  NvBufSurfaceAllocateParams p;
  memset(&p, 0, sizeof(p));
  p.params.gpuId        = 0;
  p.params.width        = w;
  p.params.height       = h;
  p.params.isContiguous = true;
  p.params.colorFormat  = NVBUF_COLOR_FORMAT_GRAY8;
  p.params.layout       = NVBUF_LAYOUT_PITCH;
  p.params.memType      = mem;
  p.disablePitchPadding = disable;
  p.memtag              = NvBufSurfaceTag_CAMERA;

  NvBufSurface *s = NULL;
  if (NvBufSurfaceAllocate(&s, 1, &p) != 0 || !s) { printf("alloc failed\n"); return; }
  s->numFilled = 1;
  printf("memType=%d disablePitchPadding=%-5s width=%4u -> pitch=%4u\n",
         (int)mem, disable ? "true" : "false", w,
         s->surfaceList[0].planeParams.pitch[0]);
  NvBufSurfaceDestroy(s);
}

int main(void) {
  const unsigned ws[] = {100, 1024, 1280, 1440, 1441, 1536, 1920};
  for (unsigned i = 0; i < sizeof(ws)/sizeof(ws[0]); i++)
    probe(NVBUF_MEM_CUDA_PINNED, true, ws[i], 1080);
  return 0;
}

Results

NVBUF_MEM_CUDA_PINNED, NVBUF_COLOR_FORMAT_GRAY8, disablePitchPadding = true, height 1080:

width pitch on R36.4.3 pitch on R39.2.1
100 100 256
1024 1024 1024
1280 1280 1280
1440 1440 1536
1441 1442 1536
1536 1536 1536
1920 1920 2048

On R36.4.3 the pitch equals the width, and for the odd width 1441 it is rounded to the next multiple of 2, which matches the header comment exactly. On R39.2.1 every pitch is rounded up to a multiple of 256 regardless of the flag.

The flag itself makes no difference on R39.2.1. Same width 1440, height 1080, GRAY8:

memType disablePitchPadding pitch on R36.4.3 pitch on R39.2.1
NVBUF_MEM_CUDA_PINNED true 1440 1536
NVBUF_MEM_CUDA_PINNED false 1536 1536
NVBUF_MEM_CUDA_UNIFIED true 1440 1536
NVBUF_MEM_CUDA_DEVICE true 1440 1536
NVBUF_MEM_SYSTEM true 1440 1536
NVBUF_MEM_DEFAULT true 1536 1536

NvBufSurfaceMap behavior is unchanged: it succeeds for CUDA_PINNED and CUDA_UNIFIED (with dataPtr == mappedAddr[0]), and fails for CUDA_DEVICE and SYSTEM, on both releases.

Documentation

The comment on the field is byte-for-byte identical in
/opt/nvidia/deepstream/deepstream-7.1/sources/includes/nvbufsurface.h (line 439) and
/opt/nvidia/deepstream/deepstream/sources/includes/nvbufsurface.h (line 489) on R39.2.1:

/** disable pitch padding allocation only applicable for cuda and system memory allocation
    pitch would be width times bytes per pixel for the plane, for odd width it would be
    multiple of 2, also note for some non standard video resolution cuda kernels may fail
    due to unaligned pitch
  */
bool disablePitchPadding;

On R39.2.1 the observed behavior does not match this description.

ABI note

sizeof(NvBufSurfaceAllocateParams) changed from 80 bytes on R36.4.3 to 120 bytes on R39.2.1, and offsetof(NvBufSurfaceAllocateParams, disablePitchPadding) moved from 44 to 80, because NvBufSurfaceCreateParams grew from 32 to 64 bytes. Our test program is compiled against the headers shipped on each board, so this is not a header/library mismatch on our side. I mention it only in case the field is being read at a stale offset somewhere inside the library.

Questions

  1. Is the 256-byte pitch alignment on R39.x intentional, with disablePitchPadding deprecated or no longer honored?
  2. If it is intentional, what is the supported way to allocate a host-mappable NvBufSurface whose pitch equals width, so that an external SDK can write tightly packed rows directly into the surface?
  3. If it is a regression, is there a release in which it will be restored, or a workaround for R39.x?

Thanks.

I am checking!

There is no update from you for a period, assuming this is not an issue anymore.
Hence, we are closing this topic. If need further support, please open a new one.
Thanks
~1013

Hi,
Would like to get more information. So in your use-case, you allocate NvBufSurface in NVBUF_MEM_CUDA_PINNED?

Hi,

Please try the attached prebuilt library for L4T R39.2.1, which addresses the reported disablePitchPadding issue with GRAY8/CUDA_PINNED.

Back up your original library and replace the following file with the attached prebuilt library:

/usr/lib/aarch64-linux-gnu/nvidia/libnvbufsurface.so.1.0.0

Please restart your application and check whether this resolves the issue in your setup.

Note: This patch adds disablePitchPadding support for the reported GRAY8/CUDA_PINNED configurtion. It does not extend support to other configurations

fixed_libnvbufsurface.tar.xz (263.5 KB)

Thanks.