nvtt
Loading...
Searching...
No Matches
Public Member Functions | List of all members
nvtt::Context Struct Reference

Compression context. More...

#include <nvtt.h>

Public Member Functions

NVTT_API Context (bool enableCuda=true)
 Create a compression context.
 
NVTT_API void enableCudaAcceleration (bool enable)
 Enable CUDA acceleration; initializes CUDA if not already initialized.
 
NVTT_API bool isCudaAccelerationEnabled () const
 Check if CUDA acceleration is enabled.
 
NVTT_API bool outputHeader (const Surface &img, int mipmapCount, const CompressionOptions &compressionOptions, const OutputOptions &outputOptions) const
 Write the Container's header to the output.
 
NVTT_API bool compress (const Surface &img, int face, int mipmap, const CompressionOptions &compressionOptions, const OutputOptions &outputOptions) const
 Compress the Surface and write the compressed data to the output.
 
NVTT_API int estimateSize (const Surface &img, int mipmapCount, const CompressionOptions &compressionOptions) const
 Returns the total compressed size of mips 0...mipmapCount-1, without compressing the image.
 
NVTT_API void quantize (Surface &tex, const CompressionOptions &compressionOptions) const
 Quantize a Surface to the number of bits per channel of the given format.
 
NVTT_API bool outputHeader (const CubeSurface &cube, int mipmapCount, const CompressionOptions &compressionOptions, const OutputOptions &outputOptions) const
 Write the Container's header to the output.
 
NVTT_API bool compress (const CubeSurface &cube, int mipmap, const CompressionOptions &compressionOptions, const OutputOptions &outputOptions) const
 Compress the CubeSurface and write the compressed data to the output.
 
NVTT_API int estimateSize (const CubeSurface &cube, int mipmapCount, const CompressionOptions &compressionOptions) const
 Returns the total compressed size of mips 0...mipmapCount-1, without compressing the image.
 
NVTT_API bool outputHeader (TextureType type, int w, int h, int d, int mipmapCount, bool isNormalMap, const CompressionOptions &compressionOptions, const OutputOptions &outputOptions) const
 Write the Container's header to the output.
 
NVTT_API bool compress (int w, int h, int d, int face, int mipmap, const float *rgba, const CompressionOptions &compressionOptions, const OutputOptions &outputOptions) const
 Compress raw data and write the compressed data to the output.
 
NVTT_API int estimateSize (int w, int h, int d, int mipmapCount, const CompressionOptions &compressionOptions) const
 Returns the total compressed size of mips 0...mipmapCount-1, without compressing the image.
 
NVTT_API bool compress (const BatchList &lst, const CompressionOptions &compressionOptions) const
 Batch processing compression interface.
 
NVTT_API void enableTiming (bool enable, int detailLevel=1)
 Enables performance measurement. May introduce additional synchronization.
 
NVTT_API TimingContextgetTimingContext ()
 Returns a TimingContext containing recorded compression performance information.
 

Detailed Description

Compression context.

Constructor & Destructor Documentation

◆ Context()

NVTT_API nvtt::Context::Context ( bool enableCuda = true)

Create a compression context.

Parameters
enableCudaIf true, enables CUDA acceleration (same as calling enableCudaAcceleration()).

Member Function Documentation

◆ compress() [1/4]

NVTT_API bool nvtt::Context::compress ( const BatchList & lst,
const CompressionOptions & compressionOptions ) const

Batch processing compression interface.

Compresses multiple inputs in a row, improving performance. Outputs data to each item's OutputHandler.

See also
BatchList
Since
NVTT 3.0

◆ compress() [2/4]

NVTT_API bool nvtt::Context::compress ( const CubeSurface & cube,
int mipmap,
const CompressionOptions & compressionOptions,
const OutputOptions & outputOptions ) const

Compress the CubeSurface and write the compressed data to the output.

Parameters
cubeThe CubeSurface.
mipmapIgnored.
compressionOptionsSpecifies the compression format.
outputOptionsSpecifies how to output the data.
Since
NVTT 2.1

◆ compress() [3/4]

NVTT_API bool nvtt::Context::compress ( const Surface & img,
int face,
int mipmap,
const CompressionOptions & compressionOptions,
const OutputOptions & outputOptions ) const

Compress the Surface and write the compressed data to the output.

Parameters
imgThe Surface.
faceIgnored.
mipmapIgnored.
compressionOptionsSpecifies the compression format.
outputOptionsSpecifies how to output the data.
Since
NVTT 2.1

◆ compress() [4/4]

NVTT_API bool nvtt::Context::compress ( int w,
int h,
int d,
int face,
int mipmap,
const float * rgba,
const CompressionOptions & compressionOptions,
const OutputOptions & outputOptions ) const

Compress raw data and write the compressed data to the output.

Note that this only supports CPU compression. For GPU support and more options, please see nvtt_lowlevel.h.

Parameters
faceIgnored.
mipmapIgnored.
rgbaColor data. Assumed to be non-interleaved; i.e. the value of channel c, pixel (x, y, z) is rgba[((c*d + z)*h + y)*w + x].
compressionOptionsSpecifies the compression format.
outputOptionsSpecifies how to output the data.
Since
NVTT 2.1

◆ enableTiming()

NVTT_API void nvtt::Context::enableTiming ( bool enable,
int detailLevel = 1 )

Enables performance measurement. May introduce additional synchronization.

See also
TimingContext
Since
NVTT 3.0

◆ estimateSize() [1/3]

NVTT_API int nvtt::Context::estimateSize ( const CubeSurface & cube,
int mipmapCount,
const CompressionOptions & compressionOptions ) const

Returns the total compressed size of mips 0...mipmapCount-1, without compressing the image.

Note that this does not include the container header, and mips are assumed to be tightly packed.

For instance, call this with mipmapCount = cube.countMipmaps() and add the size of the DDS header to get the size of a DDS file with a CubeSurface and a full mip chain.

Parameters
cubeThe CubeSurface.
mipmapCountThe number of mips (each with size max(1, s/2) of the previous) in the mip chain to be compressed.
compressionOptionsSpecifies the compression format.
Since
NVTT 2.1

◆ estimateSize() [2/3]

NVTT_API int nvtt::Context::estimateSize ( const Surface & img,
int mipmapCount,
const CompressionOptions & compressionOptions ) const

Returns the total compressed size of mips 0...mipmapCount-1, without compressing the image.

Note that this does not include the container header, and mips are assumed to be tightly packed.

For instance, call this with mipmapCount = img.countMipmaps() and add the size of the DDS header to get the size of a DDS file with a surface and a full mip chain.

Parameters
imgThe Surface.
mipmapCountThe number of mips (each with size max(1, s/2) of the previous) in the mip chain to be compressed.
compressionOptionsSpecifies the compression format.
Since
NVTT 2.1

◆ estimateSize() [3/3]

NVTT_API int nvtt::Context::estimateSize ( int w,
int h,
int d,
int mipmapCount,
const CompressionOptions & compressionOptions ) const

Returns the total compressed size of mips 0...mipmapCount-1, without compressing the image.

Note that this does not include the container header, and mips are assumed to be tightly packed.

For instance, call this with mipmapCount = nvtt::countMipmaps() and add the size of the DDS header to get the size of a DDS file with a CubeSurface and a full mip chain.

Parameters
wWidth.
hHeight.
dDepth.
mipmapCountThe number of mips (each with size max(1, s/2) of the previous) in the mip chain to be compressed.
compressionOptionsSpecifies the compression format.
Since
NVTT 2.1

◆ getTimingContext()

NVTT_API TimingContext * nvtt::Context::getTimingContext ( )

Returns a TimingContext containing recorded compression performance information.

Since
NVTT 3.0

◆ outputHeader() [1/3]

NVTT_API bool nvtt::Context::outputHeader ( const CubeSurface & cube,
int mipmapCount,
const CompressionOptions & compressionOptions,
const OutputOptions & outputOptions ) const

Write the Container's header to the output.

Parameters
cubeThe CubeSurface to read sizes from.
mipmapCountThe number of mipmaps in the container.
Since
NVTT 2.1

◆ outputHeader() [2/3]

NVTT_API bool nvtt::Context::outputHeader ( const Surface & img,
int mipmapCount,
const CompressionOptions & compressionOptions,
const OutputOptions & outputOptions ) const

Write the Container's header to the output.

Parameters
mipmapCountThe number of mipmaps in the container.
Since
NVTT 2.1

◆ outputHeader() [3/3]

NVTT_API bool nvtt::Context::outputHeader ( TextureType type,
int w,
int h,
int d,
int mipmapCount,
bool isNormalMap,
const CompressionOptions & compressionOptions,
const OutputOptions & outputOptions ) const

Write the Container's header to the output.

Parameters
mipmapCountThe number of mipmaps in the container.
Since
NVTT 2.1

◆ quantize()

NVTT_API void nvtt::Context::quantize ( Surface & tex,
const CompressionOptions & compressionOptions ) const

Quantize a Surface to the number of bits per channel of the given format.

This shouldn't be called unless you're confident you want to do this. Compressors quantize automatically, and calling this will cause compression to minimize error with respect to the quantized values, rather than the original image.

See also
nvtt::Surface::quantize()
nvtt::Surface::binarize()
Since
NVTT 3.0

The documentation for this struct was generated from the following file: