Skip to content

Commit

Permalink
vabackend: make NVCodec struct aligned
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pobrn committed Mar 21, 2022
1 parent ae5a33b commit 73ddb63
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/vabackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 73ddb63

Please sign in to comment.