From 73ddb632c2f3fb20379eb517fe5a1b7fda8c3d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Mon, 21 Mar 2022 16:16:24 +0100 Subject: [PATCH] vabackend: make NVCodec struct aligned Add the `__attribute__((aligned))` attribute to the `NVCodec` type so that it has "the maximum alignment for the target". This is needed because these structs are placed into a section of the executable and the linker will align the objects to e.g. 16-byte boundaries on x86-64 regardless of the actual size of the object. Currently, the size of this struct is just right, so this is technically not needed, but should it be extended in the future, this will prevent surprises. --- src/vabackend.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/vabackend.h b/src/vabackend.h index d9095c9..92347eb 100644 --- a/src/vabackend.h +++ b/src/vabackend.h @@ -126,13 +126,15 @@ typedef cudaVideoCodec (*ComputeCudaCodec)(VAProfile); //padding/alignment is very important to this structure as it's placed in it's own section //in the executable. -typedef struct _NVCodec +struct _NVCodec { ComputeCudaCodec computeCudaCodec; HandlerFunc handlers[VABufferTypeMax]; int supportedProfileCount; const VAProfile *supportedProfiles; -} NVCodec; +} __attribute__((aligned)); + +typedef struct _NVCodec NVCodec; void appendBuffer(AppendableBuffer *ab, const void *buf, uint64_t size); int pictureIdxFromSurfaceId(NVDriver *ctx, VASurfaceID surf);