nvtt
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions
nvtt Namespace Reference

Namespace for all public non-macro NVTT fields. More...

Classes

struct  BatchList
 Structure defining a list of inputs to be compressed. More...
 
struct  CompressionOptions
 Compression options. This class describes the desired compression format and other compression settings. More...
 
struct  Context
 Compression context. More...
 
struct  CPUInputBuffer
 Structure containing all the input images from host memory. The image data is reordered by tiles. More...
 
struct  CubeSurface
 A CubeSurface is one level of a cube map texture. More...
 
struct  EncodeSettings
 
struct  ErrorHandler
 Inheritable interface for handling errors. More...
 
struct  GPUInputBuffer
 Structure containing all the input images from device memory. The image data is reordered by tiles. More...
 
struct  OutputHandler
 Inheritable interface for outputting data. More...
 
struct  OutputOptions
 Output Options. More...
 
struct  RefImage
 Use this structure to reference each of the input images. More...
 
struct  Surface
 A surface is one level of a 2D or 3D texture. More...
 
struct  SurfaceSet
 Surface-set struct for convenience of handling multi-level texture files such as DDS, currently only supporting reading. More...
 
struct  TimingContext
 A TimingContext is a way to collect timing data from a number of functions, and report how much time each function took. More...
 

Typedefs

typedef void(* MessageCallback) (Severity severity, Error error, const char *message, const void *userData)
 

Enumerations

enum  WrapMode { WrapMode_Clamp , WrapMode_Repeat , WrapMode_Mirror }
 Wrap modes. Specifies how to handle coordinates outside the typical image range. More...
 
enum  TextureType { TextureType_2D , TextureType_Cube , TextureType_3D }
 Texture types. Specifies the dimensionality of a texture.
 
enum  InputFormat {
  InputFormat_BGRA_8UB , InputFormat_BGRA_8SB , InputFormat_RGBA_16F , InputFormat_RGBA_32F ,
  InputFormat_R_32F
}
 Input formats. Used when creating an nvtt::Surface from an RGB/RGBA array. More...
 
enum  MipmapFilter {
  MipmapFilter_Box , MipmapFilter_Triangle , MipmapFilter_Kaiser , MipmapFilter_Mitchell ,
  MipmapFilter_Min , MipmapFilter_Max
}
 Mipmap downsampling filters. Each of these can be customized using filterWidth and params when calling Surface::buildNextMipmap(). More...
 
enum  ResizeFilter {
  ResizeFilter_Box , ResizeFilter_Triangle , ResizeFilter_Kaiser , ResizeFilter_Mitchell ,
  ResizeFilter_Min , ResizeFilter_Max
}
 Texture resizing filters. More...
 
enum  RoundMode { RoundMode_None , RoundMode_ToNextPowerOfTwo , RoundMode_ToNearestPowerOfTwo , RoundMode_ToPreviousPowerOfTwo }
 Extents rounding mode. More...
 
enum  AlphaMode { AlphaMode_None , AlphaMode_Transparency , AlphaMode_Premultiplied }
 Alpha mode. More...
 
enum  Error {
  Error_None , Error_Unknown = Error_None , Error_InvalidInput , Error_UnsupportedFeature ,
  Error_CudaError , Error_FileOpen , Error_FileWrite , Error_UnsupportedOutputFormat ,
  Error_Messaging , Error_OutOfHostMemory , Error_OutOfDeviceMemory , Error_OutputWrite ,
  Error_Count
}
 Error codes. More...
 
enum  Severity { Severity_Info , Severity_Warning , Severity_Error , Severity_Count }
 Message severity. More...
 
enum  Container { Container_DDS , Container_DDS10 }
 Container type for encoded data. More...
 
enum  NormalTransform { NormalTransform_Orthographic , NormalTransform_Stereographic , NormalTransform_Paraboloid , NormalTransform_Quartic }
 Specifies a normal transformation, used to store 3D (x, y, z) normals in 2D (x, y). More...
 
enum  ToneMapper {
  ToneMapper_Linear , ToneMapper_Reinhard , ToneMapper_Reindhart = ToneMapper_Reinhard , ToneMapper_Halo ,
  ToneMapper_Lightmap
}
 Tone mapping functions. More...
 
enum  CubeLayout {
  CubeLayout_VerticalCross , CubeLayout_HorizontalCross , CubeLayout_Column , CubeLayout_Row ,
  CubeLayout_LatitudeLongitude
}
 Specifies how to fold or unfold a cube map from or to a 2D texture. More...
 
enum  EdgeFixup { EdgeFixup_None , EdgeFixup_Stretch , EdgeFixup_Warp , EdgeFixup_Average }
 Use EdgeFixup_None if unsure; this affects how certain cube surface processing algorithms work. More...
 
enum  ValueType { UINT8 , SINT8 , FLOAT32 , FLOAT16 }
 
enum  ChannelOrder {
  Red = 0 , Green = 1 , Blue = 2 , Alpha = 3 ,
  Zero = 4 , One = 5
}
 Name of channels for defining a swizzling.
 
enum  Format {
  Format_RGB , Format_RGBA = Format_RGB , Format_DXT1 , Format_DXT1a ,
  Format_DXT3 , Format_DXT5 , Format_DXT5n , Format_BC1 = Format_DXT1 ,
  Format_BC1a = Format_DXT1a , Format_BC2 = Format_DXT3 , Format_BC3 = Format_DXT5 , Format_BC3n = Format_DXT5n ,
  Format_BC4 , Format_BC4S , Format_ATI2 , Format_BC5 ,
  Format_BC5S , Format_DXT1n , Format_CTX1 , Format_BC6U ,
  Format_BC6S , Format_BC7 , Format_BC3_RGBM , Format_ASTC_LDR_4x4 ,
  Format_ASTC_LDR_5x4 , Format_ASTC_LDR_5x5 , Format_ASTC_LDR_6x5 , Format_ASTC_LDR_6x6 ,
  Format_ASTC_LDR_8x5 , Format_ASTC_LDR_8x6 , Format_ASTC_LDR_8x8 , Format_ASTC_LDR_10x5 ,
  Format_ASTC_LDR_10x6 , Format_ASTC_LDR_10x8 , Format_ASTC_LDR_10x10 , Format_ASTC_LDR_12x10 ,
  Format_ASTC_LDR_12x12 , Format_Count , Format_Unset = 255
}
 Supported block-compression formats, including compressor variants. More...
 
enum  PixelType {
  PixelType_UnsignedNorm = 0 , PixelType_SignedNorm = 1 , PixelType_UnsignedInt = 2 , PixelType_SignedInt = 3 ,
  PixelType_Float = 4 , PixelType_UnsignedFloat = 5 , PixelType_SharedExp = 6
}
 Pixel value types. More...
 
enum  Quality { Quality_Fastest , Quality_Normal , Quality_Production , Quality_Highest }
 Quality modes. More...
 
enum  EncodeFlags : uint32_t { EncodeFlags_None = 0 , EncodeFlags_UseGPU = 1 << 0 , EncodeFlags_OutputToGPUMem = 1 << 1 , EncodeFlags_Opaque = 1 << 2 }
 Encode flags for EncodeSettings. More...
 

Functions

NVTT_API unsigned int version ()
 Return the NVTT version number, as 10000*fork + 100*major + minor.
 
NVTT_API const char * errorString (Error e)
 Return string for the given error code.
 
NVTT_API bool setMessageCallback (MessageCallback callback, const void *userData)
 
NVTT_API float rmsError (const Surface &reference, const Surface &img, TimingContext *tc=0)
 Image comparison and error measurement functions. (New in NVTT 2.1)
 
NVTT_API float rmsAlphaError (const Surface &reference, const Surface &img, TimingContext *tc=0)
 Image comparison and error measurement functions. (New in NVTT 2.1)
 
NVTT_API float cieLabError (const Surface &reference, const Surface &img, TimingContext *tc=0)
 Image comparison and error measurement functions. (New in NVTT 2.1)
 
NVTT_API float angularError (const Surface &reference, const Surface &img, TimingContext *tc=0)
 Image comparison and error measurement functions. (New in NVTT 2.1)
 
NVTT_API Surface diff (const Surface &reference, const Surface &img, float scale, TimingContext *tc=0)
 Image comparison and error measurement functions. (New in NVTT 2.1)
 
NVTT_API float rmsToneMappedError (const Surface &reference, const Surface &img, float exposure, TimingContext *tc=0)
 Image comparison and error measurement functions. (New in NVTT 2.1)
 
NVTT_API Surface histogram (const Surface &img, int width, int height, TimingContext *tc=0)
 Generate histogram from surface.
 
NVTT_API Surface histogram (const Surface &img, float minRange, float maxRange, int width, int height, TimingContext *tc=0)
 Generate histogram from surface.
 
NVTT_API void getTargetExtent (int *width, int *height, int *depth, int maxExtent, RoundMode roundMode, TextureType textureType, TimingContext *tc=0)
 Geting the target extent for round-mode and texture-type. (New in NVTT 3.0)
 
NVTT_API int countMipmaps (int w, int h, int d, TimingContext *tc=0)
 Calculate the count of mipmaps given width, height, depth. (New in NVTT 3.0)
 
NVTT_API bool isCudaSupported ()
 Check if CUDA is supported by the run-time environment.
 
NVTT_API void useCurrentDevice ()
 Tells NVTT to always use an application-set device rather than selecting its own.
 
NVTT_API bool nvtt_encode (const CPUInputBuffer &input, void *output, const EncodeSettings &settings)
 
NVTT_API bool nvtt_encode (const GPUInputBuffer &input, void *output, const EncodeSettings &settings)
 
NVTT_DEPRECATED_API void nvtt_encode_bc1 (const CPUInputBuffer &input, bool fast_mode, void *output, bool useGpu=false, bool to_device_mem=false, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc1 (const GPUInputBuffer &input, bool fast_mode, void *output, bool to_device_mem=true, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc1a (const CPUInputBuffer &input, bool fast_mode, void *output, bool useGpu=false, bool to_device_mem=false, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc1a (const GPUInputBuffer &input, void *output, bool to_device_mem=true, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc2 (const CPUInputBuffer &input, bool fast_mode, void *output, bool useGpu=false, bool to_device_mem=false, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc2 (const GPUInputBuffer &input, void *output, bool to_device_mem=true, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc3 (const CPUInputBuffer &input, bool fast_mode, void *output, bool useGpu=false, bool to_device_mem=false, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc3 (const GPUInputBuffer &input, void *output, bool to_device_mem=true, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc3n (const CPUInputBuffer &input, int qualityLevel, void *output, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc3_rgbm (const CPUInputBuffer &input, void *output, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc4 (const CPUInputBuffer &input, bool slow_mode, void *output, bool useGpu=false, bool to_device_mem=false, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc4 (const GPUInputBuffer &input, void *output, bool to_device_mem=true, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc4s (const CPUInputBuffer &input, bool slow_mode, void *output, bool useGpu=false, bool to_device_mem=false, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc4s (const GPUInputBuffer &input, void *output, bool to_device_mem=true, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_ati2 (const CPUInputBuffer &input, bool slow_mode, void *output, bool useGpu=false, bool to_device_mem=false, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_ati2 (const GPUInputBuffer &input, void *output, bool to_device_mem=true, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc5 (const CPUInputBuffer &input, bool slow_mode, void *output, bool useGpu=false, bool to_device_mem=false, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc5 (const GPUInputBuffer &input, void *output, bool to_device_mem=true, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc5s (const CPUInputBuffer &input, bool slow_mode, void *output, bool useGpu=false, bool to_device_mem=false, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc5s (const GPUInputBuffer &input, void *output, bool to_device_mem=true, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc7 (const CPUInputBuffer &input, bool slow_mode, bool imageHasAlpha, void *output, bool useGpu=false, bool to_device_mem=false, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc7 (const GPUInputBuffer &input, bool imageHasAlpha, void *output, bool to_device_mem=true, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc6h (const CPUInputBuffer &input, bool slow_mode, bool is_signed, void *output, bool useGpu=false, bool to_device_mem=false, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_bc6h (const GPUInputBuffer &input, bool is_signed, void *output, bool to_device_mem=true, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_astc (const CPUInputBuffer &input, int qualityLevel, bool imageHasAlpha, void *output, bool useGpu=false, bool to_device_mem=false, nvtt::TimingContext *tc=nullptr)
 
NVTT_DEPRECATED_API void nvtt_encode_astc (const GPUInputBuffer &input, int qualityLevel, bool imageHasAlpha, void *output, bool to_device_mem=true, nvtt::TimingContext *tc=nullptr)
 

Detailed Description

Namespace for all public non-macro NVTT fields.

Typedef Documentation

◆ MessageCallback

typedef void(* nvtt::MessageCallback) (Severity severity, Error error, const char *message, const void *userData)

A MessageCallback is a function that takes a message Severity, an error enumeration (only nonzero for error messages), a null-terminated description of the message (usually with useful information for debugging; no newline at end), and a custom user pointer set when calling nvtt::SetMessageCallback().

Since
NVTT 3.2

Enumeration Type Documentation

◆ AlphaMode

Alpha mode.

Enumerator
AlphaMode_None 

This image has no alpha. The alpha channel will be ignored in some forms of compression.

AlphaMode_Transparency 

Alpha represents opacity; for instance, (r, g, b, 0.5) is a 50% opaque (r, g, b) color.

AlphaMode_Premultiplied 

Colors are stored using premultiplied alpha: (a*r, a*g, a*b, a) is an (r, g, b) color with an opacity of a. This is mostly for tracking purposes; compressors only distinguish between AlphaMode_None and AlphaMode_Transparency.

◆ Container

Container type for encoded data.

Note
For DDS containers, NVTT stores some additional data in the reserved[] fields to allow consumers to detect writer versions.
  • reserved[7] is the FourCC code "UVER", and reserved[8] stores a version number that can be set by the user.
  • reserved[9] is the FourCC code "NVTT", and reserved[10] is the NVTT writer version (which isn't necessarily the same as nvtt::version()).
For DDS containers, NVTT also extends the dwFlags field with two more flags.
  • DDPF_SRGB (0x40000000U) indicates that the texture uses an sRGB transfer function. Note that most readers will ignore this and instead guess the transfer function from the format.
  • DDPF_NORMAL (0x80000000U) indicates that the texture is a normal map.
Enumerator
Container_DDS 

DDS without the DX10 header extension. Compatible with legacy readers, but doesn't support BC6 or BC7.

Container_DDS10 

DDS without the DX10 header. Supports BC6 and BC7, but may be unreadable by legacy readers.

◆ CubeLayout

Specifies how to fold or unfold a cube map from or to a 2D texture.

Since
NVTT 2.1
Enumerator
CubeLayout_VerticalCross 

Unfolds into a 3*edgeLength (width) x 4*edgeLength texture, laid out as follows: text 2 140 3 5 Face 5 is rotated 180 degrees.

CubeLayout_HorizontalCross 

Unfolds into a 4*edgeLength (width) x 3*edgeLength texture, laid out as follows: text 2 1405 3 Face 5 is rotated 180 degrees.

CubeLayout_Column 

Writes each face in order into a column layout, like this: text 0 1 2 3 4 5

CubeLayout_Row 

Writes each face in order into a row layout, like this: text 012345

CubeLayout_LatitudeLongitude 

Same as CubeLayout_VerticalCross.

◆ EdgeFixup

Use EdgeFixup_None if unsure; this affects how certain cube surface processing algorithms work.

Enumerator
EdgeFixup_None 

No effect.

EdgeFixup_Stretch 

Slightly stretches and shifts the coordinate systems cosinePowerFilter() and fastResample() use.

EdgeFixup_Warp 

Applies a cubic warp to each face's coordinate system in cosinePowerFilter() and fastResample(), warping texels closer to edges more.

EdgeFixup_Average 

Currently unimplemented.

◆ EncodeFlags

enum nvtt::EncodeFlags : uint32_t

Encode flags for EncodeSettings.

Enumerator
EncodeFlags_UseGPU 

Compress on the GPU if CUDA is available, instead of the CPU.

EncodeFlags_OutputToGPUMem 

The output pointer is a CUDA device pointer (e.g. returned by cudaMalloc()), instead of a pointer to system memory (e.g. returned by malloc()).

EncodeFlags_Opaque 

Specifies that all pixels have an alpha component equal to 1.0f. If set, this makes compression slightly faster. It's valid to leave it unset even if the image is opaque.

◆ Error

Error codes.

See also
nvtt::ErrorHandler
errorString()
Enumerator
Error_None 

No error.

Error_Unknown 

Alias used before NVTT 3.2 for Error_None.

Error_InvalidInput 

The input to the function was invalid (for instance, a negative size).

Error_UnsupportedFeature 

Unsupported feature.

Error_CudaError 

CUDA reported an error during an operation.

Error_FileOpen 

I/O error attempting to open the given file.

Error_FileWrite 

I/O error attempting to write to the given file.

Error_UnsupportedOutputFormat 

The chosen container does not support the requested format (for instance, attempting to store BC7 data in a DDS file without the DX10 header.)

Error_Messaging 

Internal error while invoking the message callback.

Since
NVTT 3.2
Error_OutOfHostMemory 

Out of host memory (allocating a CPU-side buffer failed).

Since
NVTT 3.2
Error_OutOfDeviceMemory 

Out of device memory (allocating a GPU-side buffer failed).

Since
NVTT 3.2
Error_OutputWrite 

OutputOptions::writeData() returned false.

Since
NVTT 3.2

◆ Format

Supported block-compression formats, including compressor variants.

That is:

  • 'DXT1' is a format, 'DXT1a' and 'DXT1n' are DXT1 compressors.
  • 'DXT3' is a format, 'DXT3n' is a DXT3 compressor.
Enumerator
Format_RGB 

Linear RGB format.

Format_RGBA 

Linear RGBA format.

Format_DXT1 

DX9 - DXT1 format.

Format_DXT1a 

DX9 - DXT1 with binary alpha.

Format_DXT3 

DX9 - DXT3 format.

Format_DXT5 

DX9 - DXT5 format.

Format_DXT5n 

DX9 - DXT5 normal format. Stores a normal (x, y, z) as (R, G, B, A) = (1, y, 0, x).

Format_BC1 

DX10 - BC1 (DXT1) format.

Format_BC1a 

DX10 - BC1 (DXT1) format.

Format_BC2 

DX10 - BC2 (DXT3) format.

Format_BC3 

DX10 - BC3 (DXT5) format.

Format_BC3n 

DX10 - BC3 (DXT5) normal format for improved compression, storing a normal (x, y, z) as (1, y, 0, x).

Format_BC4 

DX10 - BC4U (ATI1) format (one channel, unsigned)

Format_BC4S 

DX10 - BC4S format (one channel, signed)

Format_ATI2 

DX10 - ATI2 format, similar to BC5U, channel order GR instead of RG.

Format_BC5 

DX10 - BC5U format (two channels, unsigned)

Format_BC5S 

DX10 - BC5S format (two channels, signed)

Format_DXT1n 

Not supported.

Format_CTX1 

Not supported.

Format_BC6U 

DX10 - BC6 format (three-channel HDR, unsigned)

Format_BC6S 

DX10 - BC6 format (three-channel HDR, signed)

Format_BC7 

DX10 - BC7 format (four channels, UNORM)

Format_BC3_RGBM 

DX10 - BC3(DXT5) - using a magnitude encoding to approximate three-channel HDR data in four UNORM channels. The input should be in the range [0,1], and this should give more accurate values closer to 0. On most devices, consider using BC6 instead.

To decompress this format, decompress it like a standard BC3 texture, then compute (R, G, B) from (r, g, b, m) using fromRGBM() with range = 1 and threshold = 0.25:

M = m * 0.75 + 0.25;

(R, G, B) = (r, g, b) * M

The idea is that since BC3 uses separate compression for the RGB and alpha blocks, the RGB and M signals can be independent. Additionally, the compressor can account for the RGB compression error. This will print warnings if any of the computed m values were greater than 1.0.

Format_ASTC_LDR_4x4 

ASTC - LDR - format, tile size 4x4.

Format_ASTC_LDR_5x4 

ASTC - LDR - format, tile size 5x4.

Format_ASTC_LDR_5x5 

ASTC - LDR - format, tile size 5x5.

Format_ASTC_LDR_6x5 

ASTC - LDR - format, tile size 6x5.

Format_ASTC_LDR_6x6 

ASTC - LDR - format, tile size 6x6.

Format_ASTC_LDR_8x5 

ASTC - LDR - format, tile size 8x5.

Format_ASTC_LDR_8x6 

ASTC - LDR - format, tile size 8x6.

Format_ASTC_LDR_8x8 

ASTC - LDR - format, tile size 8x8.

Format_ASTC_LDR_10x5 

ASTC - LDR - format, tile size 10x5.

Format_ASTC_LDR_10x6 

ASTC - LDR - format, tile size 10x6.

Format_ASTC_LDR_10x8 

ASTC - LDR - format, tile size 10x8.

Format_ASTC_LDR_10x10 

ASTC - LDR - format, tile size 10x10.

Format_ASTC_LDR_12x10 

ASTC - LDR - format, tile size 12x10.

Format_ASTC_LDR_12x12 

ASTC - LDR - format, tile size 12x12.

Format_Unset 

Placeholder in structs to produce errors if a format is not explicitly set, since format 0 is Format_RGB.

◆ InputFormat

Input formats. Used when creating an nvtt::Surface from an RGB/RGBA array.

Enumerator
InputFormat_BGRA_8UB 

[0, 255] 8 bit uint

InputFormat_BGRA_8SB 

[-127, 127] 8 bit int

InputFormat_RGBA_16F 

16 bit floating point.

InputFormat_RGBA_32F 

32 bit floating point.

InputFormat_R_32F 

Single channel 32 bit floating point.

◆ MipmapFilter

Mipmap downsampling filters. Each of these can be customized using filterWidth and params when calling Surface::buildNextMipmap().

Enumerator
MipmapFilter_Box 

Box filter is quite good and very fast. It has some special paths for downsampling by exactly a factor of 2. filterWidth defaults to 0.5; box(x) is equal to 1 when |x| < filterWidth and 0 otherwise.

MipmapFilter_Triangle 

Triangle filter blurs the results too much, but that might be what you want. filterWidth defaults to 1.0; triangle(x) is equal to filterWidth - |x| when |x| < filterWidth and 0 otherwise.

MipmapFilter_Kaiser 

Kaiser-windowed Sinc filter is the best downsampling filter, and close to a mathematically ideal windowing filter. If the window size is too large, it can introduce ringing.

filterWidth controls the width of the Kaiser window. Larger values take longer to compute and include more oscillations of the sinc filter.

param[0] (default: 4.0f) sets alpha, the sharpness of the Kaiser window. Higher values make the main lobe wider, but reduce sideband energy.

param[1] (default: 1.0f) controls the frequency of the sinc filter. Higher values include higher frequencies.

See also
https://en.wikipedia.org/wiki/Kaiser_window
MipmapFilter_Mitchell 

Mitchell & Netravali's two parameter cubic filter.

See also
nvtt::MipmapFilter::MipmapFilter_Mitchell

filterWidth (default: 2.0f) can truncate the filter, but should usually be left at the default.

param[0] (default: 1/3) sets B.

param[1] (default: 2/3) sets C.

See also
"Reconstruction Filters in Computer Graphics", SIGGRAPH 1988
https://en.wikipedia.org/wiki/Mitchell%E2%80%93Netravali_filters
MipmapFilter_Min 

Takes the minimum over all input texels that contribute to each output texel.

This is especially useful for generating mipmaps for parallax occlusion mapping, or for structures like hierarchical Z-buffers.

Specifically, this acts as if for an X x Y x Z image, the texel at (i, j, k) covers the open box (i/X, (i+1)/X) x (j/Y, (j+1)/Y) x (k/Z, (k+1)/Z).

Then for each output texel, the set of contributing texels is the set of input texels whose boxes intersect the output texel's box.

MipmapFilter_Max 

Like MipmapFilter_Min, but takes the maximum over all contributing texels instead of the minimum.

◆ NormalTransform

Specifies a normal transformation, used to store 3D (x, y, z) normals in 2D (x, y).

We define these in terms of their 2D -> 3D reconstructions, since their transformations are the inverse of the reconstructions. Most require z >= 0.0f.

See also
Surface::transformNormals()
Surface::reconstructNormals()
Since
NVTT 2.1
Enumerator
NormalTransform_Orthographic 

Reconstructs the z component using z = sqrt(1 - x^2 + y^2).

NormalTransform_Stereographic 

Stereographic projection (like looking from the bottom of the sphere of normals and projecting points onto a plane at z = 1). Reconstructed using d = 2/(1 + min(x^2 + y^2, 1)); return (x*d, y*d, d-1).

NormalTransform_Paraboloid 

Reconstructed using normalize(x, y, 1 - min(x^2 + y^2, 1)).

NormalTransform_Quartic 

Reconstructed using normalize(x, y, (1-x^2)(1-y^2)).

◆ PixelType

Pixel value types.

These are used for Format_RGB: they indicate how the output should be interpreted, but do not have any influence over the input. They are ignored for other compression modes.

Enumerator
PixelType_UnsignedNorm 

Used to indicate a DXGI_..._UNORM format.

PixelType_SignedNorm 

Not supported yet.

PixelType_UnsignedInt 

Not supported yet.

PixelType_SignedInt 

Not supported yet.

PixelType_Float 

Used to indicate a DXGI_..._FLOAT format.

PixelType_UnsignedFloat 

Used to indicate a DXGI_..._UF16 format. Unused.

PixelType_SharedExp 

Shared exponent. Only supported for DXGI_FORMAT_R9G9B9E5_SHAREDEXP.

◆ Quality

Quality modes.

These can be used to trade off speed of compression for lower error, and often selects the specific compression algorithm that will be used. Here's a table showing which (format, quality) combinations support CUDA acceleration:

Quality BC1 BC1a BC2 BC3 BC3n RGBM BC4 BC5 BC6 BC7 ASTC
Fastest Yes No No No No No Yes Yes Yes Yes Yes
Normal Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes
Production Yes Yes Yes Yes Yes No No No No No (slow) Yes
Highest Yes Yes Yes Yes Yes No No No No No (slow) Yes

See the documentation of the different compression functions in nvtt_lowlevel.h for more information.

◆ ResizeFilter

Texture resizing filters.

Enumerator
ResizeFilter_Box 

Box filter. Fast, but produces nearest-neighbor artifacts when upsampling.

See also
nvtt::MipmapFilter::MipmapFilter_Box
ResizeFilter_Triangle 

Triangle (tent) filter. It can blur the results too much, but that might be what you want.

See also
nvtt::MipmapFilter::MipmapFilter_Triangle
ResizeFilter_Kaiser 

Kaiser-windowed Sinc filter.

See also
nvtt::MipmapFilter::MipmapFilter_Kaiser
ResizeFilter_Mitchell 

Mitchell & Netravali's two parameter cubic filter.

See also
nvtt::MipmapFilter::MipmapFilter_Mitchell
ResizeFilter_Min 

Takes the minimum over all contributing texels.

See also
nvtt::MipmapFilter::MipmapFilter_Min
ResizeFilter_Max 

Takes the maximum over all contributing texels.

See also
nvtt::MipmapFilter::MipmapFilter_Max

◆ RoundMode

Extents rounding mode.

Determines how to round sizes to different sets when shrinking an image.

For each of the PowerOfTwo modes, maxExtent is first rounded to the previous power of two.

Then all extents are scaled and truncated without changing the aspect ratio, using s = max((s * maxExtent) / m, 1), where m is the maximum width, height, or depth.

If the texture is a cube map, the width and height are then averaged to make the resulting texture square.

Finally, extents are rounded to a set of possible sizes depending on this enum.

See also
getTargetExtent()
Enumerator
RoundMode_None 

Each extent is left as-is.

RoundMode_ToNextPowerOfTwo 

Each extent is rounded up to the next power of two.

RoundMode_ToNearestPowerOfTwo 

Each extent is rounded either up or down to the nearest power of two.

RoundMode_ToPreviousPowerOfTwo 

Each element is rounded down to the next power of two.

◆ Severity

Message severity.

Since
NVTT 3.2
Enumerator
Severity_Info 

An informative message, such as statistics or current computation progress.

Severity_Warning 

A warning. For instance, an app may get a warning if it tries to enable CUDA acceleration, but no CUDA driver is available (which requires NVTT to use its CPU fallbacks).

Severity_Error 

An error. For instance, an API may have been called incorrectly, or CUDA may have run out of memory. The Error field of the message callback will be set to an appropriate value.

◆ ToneMapper

Tone mapping functions.

Since
NVTT 2.1
Enumerator
ToneMapper_Linear 

Colors inside [0,1)^3 are preserved; colors outside are tone mapped using (r', g', b') = (r, g, b)/max(r, g, b). This clamps colors to the RGB cube, but preserves hue. It is not invertible.

ToneMapper_Reinhard 

Applies a Reinhard operator to each channel: c' = c / (c + 1).

ToneMapper_Reindhart 

Name for backwards compatibility.

See also
ToneMapper_Reinhard
ToneMapper_Halo 

Applies an exponential tone mapper to each channel: c' = 1 - 2^(-c).

ToneMapper_Lightmap 

Same as ToneMapper_Linear.

◆ ValueType

Value type of the input images. The input buffer will use the same value type as the input images

Enumerator
UINT8 

8-bit unsigned integer.

SINT8 

8-bit signed integer. Can be casted to float by dividing by 127, with the exception that both -128 and -127 represent -1.0f.

FLOAT32 

IEEE 754 single-precision floating-point: 1 sign bit, 8 exponent bits, and 23 mantissa bits.

FLOAT16 

IEEE 754 half-precision floating-point: 1 sign bit, 5 exponent bits, and 10 mantissa bits.

◆ WrapMode

Wrap modes. Specifies how to handle coordinates outside the typical image range.

Enumerator
WrapMode_Clamp 

Coordinates are clamped, moving them to the closest coordinate inside the image.

WrapMode_Repeat 

The image is treated as if it repeats on both axes, mod each dimension. For instance, for a 4x4 image, (5, -2) wraps to (1, 2).

WrapMode_Mirror 

Coordinates are treated as if they reflect every time they pass through the center of an edge texel. For instance, for a 10x10 image, (8, 0), (10, 0), (26, 0), and (28, 0) all mirror to (8, 0).

Function Documentation

◆ nvtt_encode() [1/2]

NVTT_API bool nvtt::nvtt_encode ( const CPUInputBuffer & input,
void * output,
const EncodeSettings & settings )

Low-level interface for compressing to any of NVTT's formats from a CPUInputBuffer. If encoding succeeded, returns true. On failure, logs at least one error (

See also
nvtt::setMessageCallback()) and returns false.

Here's an example of how to encode data in CPU memory to BC7 format on the GPU, writing the output to CUDA device memory:

// Given void* d_outputData, a pointer to where the compressed data
// should be written on the GPU, and a CPUInputBuffer cpuInput:
using namespace nvtt;
const auto settings = EncodeSettings().SetFormat(Format_BC7)
if (nvtt_encode(cpuInput, d_outputData, settings))
{
// Encoding succeeded! Do something with the data here.
}
Namespace for all public non-macro NVTT fields.
Definition nvtt.h:52
@ Format_BC7
DX10 - BC7 format (four channels, UNORM)
Definition nvtt_lowlevel.h:248
NVTT_API bool nvtt_encode(const CPUInputBuffer &input, void *output, const EncodeSettings &settings)
Definition nvtt_lowlevel.h:388
NVTT_API EncodeSettings & SetFormat(Format _format)
NVTT_API EncodeSettings & SetOutputToGPUMem(bool _to_device_mem)
Parameters
inputConstant reference to input in CPU memory.
outputPointer to output: CUDA device pointer if settings.encode_flags includes ENCODE_USE_GPU, and a pointer to CPU memory otherwise.
settingsEncoder settings, including the compression format and quality.
Since
NVTT 3.2

◆ nvtt_encode() [2/2]

NVTT_API bool nvtt::nvtt_encode ( const GPUInputBuffer & input,
void * output,
const EncodeSettings & settings )

Low-level interface for compressing to any of NVTT's formats from a GPUInputBuffer. If encoding succeeded, returns true. On failure, logs at least one error (

See also
nvtt::setMessageCallback()) and returns false.

Here's an example of how to encode data in GPU memory to BC7 format on the GPU, writing the output to CUDA device memory:

// Given void* d_outputData, a pointer to where the compressed data
// should be written on the GPU, and a GPUInputBuffer gpuInput:
using namespace nvtt;
const auto settings = EncodeSettings().SetFormat(Format_BC7)
if (nvtt_encode(gpuInput, d_outputData, settings))
{
// Encoding succeeded! Do something with the data here.
}
Parameters
inputConstant reference to input in GPU memory.
outputPointer to output: CUDA device pointer if settings.encode_flags includes ENCODE_USE_GPU, and a pointer to CPU memory otherwise.
settingsEncoder settings, including the compression format and quality.
Note
Clearing settings flag ENCODE_USE_GPU is ignored; data compressed using this function is currently always compressed on the GPU.
Since
NVTT 3.2

◆ nvtt_encode_astc() [1/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_astc ( const CPUInputBuffer & input,
int qualityLevel,
bool imageHasAlpha,
void * output,
bool useGpu = false,
bool to_device_mem = false,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to ASTC format from CPUInputBuffer. This supports 4 quality levels on both the CPU and GPU.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in CPU memory.
qualityLevelThe quality level, 0, 1, 2, or 3. Higher quality levels produce less compression error, but take longer.
imageHasAlphaSpecifies that some pixels in the image have an alpha value less than 1.0f. If false, this makes compression slightly faster. It's still valid to set it to true even if the image is opaque.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
useGpuWhether to run the compression algorithm on the GPU as opposed to the CPU. See note on slow_mode.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_astc() [2/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_astc ( const GPUInputBuffer & input,
int qualityLevel,
bool imageHasAlpha,
void * output,
bool to_device_mem = true,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to ASTC format from GPUInputBuffer, always using GPU compression. This supports 4 quality levels.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in GPU memory.
qualityLevelThe quality level, 0, 1, 2, or 3. Higher quality levels produce less compression error, but take longer.
imageHasAlphaSpecifies that some pixels in the image have an alpha value less than 1.0f. If false, this makes compression slightly faster. It's still valid to set it to true even if the image is opaque.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_ati2() [1/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_ati2 ( const CPUInputBuffer & input,
bool slow_mode,
void * output,
bool useGpu = false,
bool to_device_mem = false,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to ATI2 format from CPUInputBuffer. No slow-mode algorithm for the GPU is available, so when slow_mode is true this ignores useGPU and compresses on the CPU.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in CPU memory.
slow_modeIf true, uses a slower but higher-quality compressor; otherwise, uses a faster but lower-quality compressor. Also overrides useGPU if true and uses the CPU for slow-mode compression.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
useGpuWhether to run the compression algorithm on the GPU as opposed to the CPU. See note on slow_mode.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_ati2() [2/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_ati2 ( const GPUInputBuffer & input,
void * output,
bool to_device_mem = true,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to ATI2 format from GPUInputBuffer, always using GPU compression. This method has only one quality level, corresponding to CPU fast-mode.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in GPU memory.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc1() [1/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc1 ( const CPUInputBuffer & input,
bool fast_mode,
void * output,
bool useGpu = false,
bool to_device_mem = false,
nvtt::TimingContext * tc = nullptr )

NVTT 3's initial implementation of the low-level compression API below used a different function for each combination of the encoding format category and the input type. Because these functions have different signatures, we recommend using NVTT 3.2's nvtt_encode API above. The functions below are provided for backwards compatibility and will remain supported for all versions of NVTT 3. Interface for compressing to BC1 format from CPUInputBuffer.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in CPU memory.
fast_modeIf true, uses a faster but lower-quality compressor; otherwise, uses a slower but higher-quality compressor. This applies to both CPU and GPU compression.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
useGpuWhether to run the compression algorithm on the GPU as opposed to the CPU.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc1() [2/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc1 ( const GPUInputBuffer & input,
bool fast_mode,
void * output,
bool to_device_mem = true,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC1 format from GPUInputBuffer, always using GPU compression.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in GPU memory.
fast_modeIf true, uses a faster but lower-quality compressor; otherwise, uses a slower but higher-quality compressor. Compression always happens on the GPU, so CUDA must be available.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc1a() [1/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc1a ( const CPUInputBuffer & input,
bool fast_mode,
void * output,
bool useGpu = false,
bool to_device_mem = false,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC1a format from CPUInputBuffer. No fast-mode algorithm for the GPU is available, so when fast_mode is true this ignores useGPU and compresses on the CPU. In this case, slow-mode GPU compression may be faster than fast-mode CPU compression.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in CPU memory.
fast_modeIf true, uses a faster but lower-quality compressor; otherwise, uses a slower but higher-quality compressor. Also overrides useGPU if true and uses the CPU for fast-mode compression.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
useGpuWhether to run the compression algorithm on the GPU as opposed to the CPU. See note on fast_mode.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc1a() [2/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc1a ( const GPUInputBuffer & input,
void * output,
bool to_device_mem = true,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC1a format from GPUInputBuffer, always using GPU compression. This method has only one quality level, corresponding to CPU slow-mode.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in GPU memory.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc2() [1/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc2 ( const CPUInputBuffer & input,
bool fast_mode,
void * output,
bool useGpu = false,
bool to_device_mem = false,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC2 format from CPUInputBuffer. No fast-mode algorithm for the GPU is available, so when fast_mode is true this ignores useGPU and compresses on the CPU. In this case, slow-mode GPU compression may be faster than fast-mode CPU compression.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in CPU memory.
fast_modeIf true, uses a faster but lower-quality compressor; otherwise, uses a slower but higher-quality compressor. Also overrides useGPU if true and uses the CPU for fast-mode compression.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
useGpuWhether to run the compression algorithm on the GPU as opposed to the CPU. See note on fast_mode.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc2() [2/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc2 ( const GPUInputBuffer & input,
void * output,
bool to_device_mem = true,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC2 format from GPUInputBuffer, always using GPU compression. This method has only one quality level, corresponding to CPU slow-mode.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in GPU memory.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc3() [1/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc3 ( const CPUInputBuffer & input,
bool fast_mode,
void * output,
bool useGpu = false,
bool to_device_mem = false,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC3 format from CPUInputBuffer. No fast-mode algorithm for the GPU is available, so when fast_mode is true this ignores useGPU and compresses on the CPU. In this case, slow-mode GPU compression may be faster than fast-mode CPU compression.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in CPU memory.
fast_modeIf true, uses a faster but lower-quality compressor; otherwise, uses a slower but higher-quality compressor. Also overrides useGPU if true and uses the CPU for fast-mode compression.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
useGpuWhether to run the compression algorithm on the GPU as opposed to the CPU. See note on fast_mode.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc3() [2/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc3 ( const GPUInputBuffer & input,
void * output,
bool to_device_mem = true,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC3 format from GPUInputBuffer, always using GPU compression. This method has only one quality level, corresponding to CPU slow-mode.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in GPU memory.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc3_rgbm()

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc3_rgbm ( const CPUInputBuffer & input,
void * output,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC3 - rgbm format from CPUInputBuffer. This method is currently CPU-only and has 1 quality level. See nvtt::Format_BC3_RGBM.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in CPU memory.
outputPointer to output in CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc3n()

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc3n ( const CPUInputBuffer & input,
int qualityLevel,
void * output,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC3n format from CPUInputBuffer. This method is currently CPU-only, but supports 3 quality levels

Parameters
inputConstant reference to input in CPU memory.
qualityLevelHigher quality levels produce less compression error, but take longer to compress. Can be 0, 1, or 2.
outputPointer to output in CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc4() [1/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc4 ( const CPUInputBuffer & input,
bool slow_mode,
void * output,
bool useGpu = false,
bool to_device_mem = false,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC4U format from CPUInputBuffer. No slow-mode algorithm for the GPU is available, so when slow_mode is true this ignores useGPU and compresses on the CPU.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in CPU memory.
slow_modeIf true, uses a slower but higher-quality compressor; otherwise, uses a faster but lower-quality compressor. Also overrides useGPU if true and uses the CPU for slow-mode compression.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
useGpuWhether to run the compression algorithm on the GPU as opposed to the CPU. See note on slow_mode.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc4() [2/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc4 ( const GPUInputBuffer & input,
void * output,
bool to_device_mem = true,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC4U format from GPUInputBuffer, always using GPU compression. This method has only one quality level, corresponding to CPU fast-mode.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in GPU memory.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc4s() [1/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc4s ( const CPUInputBuffer & input,
bool slow_mode,
void * output,
bool useGpu = false,
bool to_device_mem = false,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC4S format from CPUInputBuffer. No slow-mode algorithm for the GPU is available, so when slow_mode is true this ignores useGPU and compresses on the CPU.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in CPU memory.
slow_modeIf true, uses a slower but higher-quality compressor; otherwise, uses a faster but lower-quality compressor. Also overrides useGPU if true and uses the CPU for slow-mode compression.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
useGpuWhether to run the compression algorithm on the GPU as opposed to the CPU. See note on slow_mode.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc4s() [2/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc4s ( const GPUInputBuffer & input,
void * output,
bool to_device_mem = true,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC4S format from GPUInputBuffer, always using GPU compression. This method has only one quality level, corresponding to CPU fast-mode.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in GPU memory.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc5() [1/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc5 ( const CPUInputBuffer & input,
bool slow_mode,
void * output,
bool useGpu = false,
bool to_device_mem = false,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC5U format from CPUInputBuffer. No slow-mode algorithm for the GPU is available, so when slow_mode is true this ignores useGPU and compresses on the CPU.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in CPU memory.
slow_modeIf true, uses a slower but higher-quality compressor; otherwise, uses a faster but lower-quality compressor. Also overrides useGPU if true and uses the CPU for slow-mode compression.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
useGpuWhether to run the compression algorithm on the GPU as opposed to the CPU. See note on slow_mode.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc5() [2/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc5 ( const GPUInputBuffer & input,
void * output,
bool to_device_mem = true,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC5U format from GPUInputBuffer, always using GPU compression. This method has only one quality level, corresponding to CPU fast-mode.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in GPU memory.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc5s() [1/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc5s ( const CPUInputBuffer & input,
bool slow_mode,
void * output,
bool useGpu = false,
bool to_device_mem = false,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC5S format from CPUInputBuffer. No slow-mode algorithm for the GPU is available, so when slow_mode is true this ignores useGPU and compresses on the CPU.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in CPU memory.
slow_modeIf true, uses a slower but higher-quality compressor; otherwise, uses a faster but lower-quality compressor. Also overrides useGPU if true and uses the CPU for slow-mode compression.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
useGpuWhether to run the compression algorithm on the GPU as opposed to the CPU. See note on slow_mode.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc5s() [2/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc5s ( const GPUInputBuffer & input,
void * output,
bool to_device_mem = true,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC5S format from GPUInputBuffer, always using GPU compression. This method has only one quality level, corresponding to CPU fast-mode.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in GPU memory.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc6h() [1/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc6h ( const CPUInputBuffer & input,
bool slow_mode,
bool is_signed,
void * output,
bool useGpu = false,
bool to_device_mem = false,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC6H format from CPUInputBuffer. No slow-mode algorithm for the GPU is available, so when slow_mode is true this ignores useGPU and compresses on the CPU.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in CPU memory.
slow_modeIf true, uses a slower but higher-quality compressor; otherwise, uses a faster but lower-quality compressor. Also overrides useGPU if true and uses the CPU for slow-mode compression.
is_signedIf true, compresses to the BC6S format, instead of BC6U.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
useGpuWhether to run the compression algorithm on the GPU as opposed to the CPU. See note on slow_mode.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc6h() [2/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc6h ( const GPUInputBuffer & input,
bool is_signed,
void * output,
bool to_device_mem = true,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC6H format from GPUInputBuffer, always using GPU compression. This method has only one quality level, corresponding to CPU fast-mode.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in GPU memory.
is_signedIf true, compresses to the BC6S format, instead of BC6U.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc7() [1/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc7 ( const CPUInputBuffer & input,
bool slow_mode,
bool imageHasAlpha,
void * output,
bool useGpu = false,
bool to_device_mem = false,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC7 format from CPUInputBuffer. No slow-mode algorithm for the GPU is available, so when slow_mode is true this ignores useGPU and compresses on the CPU. The slow-mode CPU compressor is particularly slow in this case (as it searches though a very large space of possibilities), so fast-mode compression is recommended.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in CPU memory.
slow_modeIf true, uses a slower but higher-quality compressor; otherwise, uses a faster but lower-quality compressor. Also overrides useGPU if true and uses the CPU for slow-mode compression.
imageHasAlphaSpecifies that some pixels in the image have an alpha value less than 1.0f. If false, this makes compression slightly faster. It's still valid to set it to true even if the image is opaque.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
useGpuWhether to run the compression algorithm on the GPU as opposed to the CPU. See note on slow_mode.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ nvtt_encode_bc7() [2/2]

NVTT_DEPRECATED_API void nvtt::nvtt_encode_bc7 ( const GPUInputBuffer & input,
bool imageHasAlpha,
void * output,
bool to_device_mem = true,
nvtt::TimingContext * tc = nullptr )

Interface for compressing to BC7 format from GPUInputBuffer, always using GPU compression. This method has only one quality level, corresponding to CPU fast-mode.

Deprecated
nvtt_encode() is more general and consistent. This function is now only a wrapper for an nvtt_encode() call.
Parameters
inputConstant reference to input in GPU memory.
imageHasAlphaSpecifies that some pixels in the image have an alpha value less than 1.0f. If false, this makes compression slightly faster. It's still valid to set it to true even if the image is opaque.
outputPointer to output: CUDA device pointer if to_device_mem is true, and a pointer to CPU memory otherwise.
to_device_memSpecifies that output is a CUDA device pointer, rather than a pointer to CPU memory.
tcTiming context for recording performance information.

◆ setMessageCallback()

NVTT_API bool nvtt::setMessageCallback ( MessageCallback callback,
const void * userData )

Sets the current thread's NVTT MessageCallback. NVTT calls this function whenever it encounters an error or performance warning, or has useful information. Here's an example showing how to use a message callback to detect and print errors:

thread_local bool caughtError = false;
void customCallback(nvtt::Severity severity, nvtt::Error error,
const char* message, const void* userData)
{
if (severity == nvtt::Severity_Error)
{
printf("ERROR: %s\n", message);
caughtError = true;
}
}
// Example processing function; returns true on success
bool exampleProcessing(...)
{
nvtt::setMessageCallback(customCallback, nullptr);
GPUInputBuffer input(...);
nvtt_encode_bc7(input, ...);
return !caughtError;
}
Severity
Message severity.
Definition nvtt.h:349
@ Severity_Error
Definition nvtt.h:360
NVTT_DEPRECATED_API void nvtt_encode_bc7(const CPUInputBuffer &input, bool slow_mode, bool imageHasAlpha, void *output, bool useGpu=false, bool to_device_mem=false, nvtt::TimingContext *tc=nullptr)
NVTT_API bool setMessageCallback(MessageCallback callback, const void *userData)
Error
Error codes.
Definition nvtt.h:317

Since each thread has its own callback pointer, a custom callback should be set whenever an app creates a new thread. If no callback has been set, the default callback prints the severity and the message, followed by a newline, to stdout. If a callback has been set, setting the callback to nullptr will make NVTT switch to the default callback. Returns true if setting the message callback succeeded.

Since
NVTT 3.2

◆ useCurrentDevice()

NVTT_API void nvtt::useCurrentDevice ( )

Tells NVTT to always use an application-set device rather than selecting its own.

By default, NVTT functions such as nvtt::isCudaSupported() and nvtt::Context() can choose a device and call cudaSetDevice(). Calling this function will prevent NVTT from calling cudaSetDevice(), and will make it use the currently set device instead. The application must then call cudaSetDevice() before calling NVTT functions, and whenever it wants to change the device subsequent NVTT functions will use.

For instance, this may be useful when managing devices on multi-GPU systems.