summaryrefslogtreecommitdiff
path: root/thirdparty/thekla_atlas/nvimage/nvimage.h
blob: 5c89bd4726e2e30a3ffca86bfaa1413ff2dbd421 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// This code is in the public domain -- castanyo@yahoo.es

#pragma once
#ifndef NV_IMAGE_H
#define NV_IMAGE_H

#include "nvcore/nvcore.h"
#include "nvcore/Debug.h" // nvDebugCheck
#include "nvcore/Utils.h" // isPowerOfTwo

// Function linkage
#if NVIMAGE_SHARED
#ifdef NVIMAGE_EXPORTS
#define NVIMAGE_API DLL_EXPORT
#define NVIMAGE_CLASS DLL_EXPORT_CLASS
#else
#define NVIMAGE_API DLL_IMPORT
#define NVIMAGE_CLASS DLL_IMPORT
#endif
#else
#define NVIMAGE_API
#define NVIMAGE_CLASS
#endif


namespace nv {

    // Some utility functions:

    inline uint computeBitPitch(uint w, uint bitsize, uint alignmentInBits)
    {
        nvDebugCheck(isPowerOfTwo(alignmentInBits));

        return ((w * bitsize +  alignmentInBits - 1) / alignmentInBits) * alignmentInBits;
    }

    inline uint computeBytePitch(uint w, uint bitsize, uint alignmentInBytes)
    {
        uint pitch = computeBitPitch(w, bitsize, 8*alignmentInBytes);
        nvDebugCheck((pitch & 7) == 0);

        return (pitch + 7) / 8;
    }


} // nv namespace

#endif // NV_IMAGE_H