nvtt: nvtt/nvtt.h Source File

nvtt

Loading...
Searching...
No Matches
nvtt.h
Go to the documentation of this file.
1// Copyright (c) 2015 ~ 2019 NVIDIA Corporation
2//
3// Permission is hereby granted, free of charge, to any person
4// obtaining a copy of this software and associated documentation
5// files (the "Software"), to deal in the Software without
6// restriction, including without limitation the rights to use,
7// copy, modify, merge, publish, distribute, sublicense, and/or sell
8// copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following
10// conditions:
11//
12// The above copyright notice and this permission notice shall be
13// included in all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22// OTHER DEALINGS IN THE SOFTWARE.
23
26
27#ifndef NVTT_H
28#define NVTT_H
29
30#include "nvtt_lowlevel.h"
31
34#define NVTT_VERSION 30205
35
37#define NVTT_FORBID_COPY(Class) \
38 private: \
39 Class(const Class &); \
40 void operator=(const Class &); \
41 public:
42
45#define NVTT_DECLARE_PIMPL(Class) \
46 public: \
47 struct Private; \
48 Private & m;
49
51 namespace nvtt
52{
54 NVTT_API unsigned int version();
55
56 // Forward declarations.
57 struct Surface;
58 struct CubeSurface;
59 struct TimingContext;
60 struct BatchList;
61
63 struct CompressionOptions
64 {
65 NVTT_FORBID_COPY(CompressionOptions)
66 NVTT_DECLARE_PIMPL(CompressionOptions)
67
68
69 NVTT_API CompressionOptions();
70
72 NVTT_API ~CompressionOptions();
73
75 NVTT_API void reset();
76
78 NVTT_API void setFormat(Format format);
79
81 NVTT_API void setQuality(Quality quality);
82
89 NVTT_API void setColorWeights(float red, float green, float blue, float alpha = 1.0f);
90
94 NVTT_API void setPixelFormat(unsigned int bitcount, unsigned int rmask, unsigned int gmask, unsigned int bmask, unsigned int amask);
95
99 NVTT_API void setPixelFormat(unsigned char rsize, unsigned char gsize, unsigned char bsize, unsigned char asize);
100
106 NVTT_API void setPixelType(PixelType pixelType);
107
109 NVTT_API void setPitchAlignment(int pitchAlignment);
110
117 NVTT_API void setQuantization(bool colorDithering, bool alphaDithering, bool binaryAlpha, int alphaThreshold = 127);
118
128 NVTT_API unsigned int d3d9Format() const;
129 };
130
132 enum WrapMode
133 {
136 WrapMode_Clamp,
139 WrapMode_Repeat,
143 WrapMode_Mirror,
144 };
145
147 enum TextureType
148 {
149 TextureType_2D,
150 TextureType_Cube,
151 TextureType_3D,
152 };
153
155 enum InputFormat
156 {
157 InputFormat_BGRA_8UB,
158 InputFormat_BGRA_8SB,
159 InputFormat_RGBA_16F,
160 InputFormat_RGBA_32F,
161 InputFormat_R_32F,
162 };
163
166 enum MipmapFilter
167 {
172 MipmapFilter_Box,
176 MipmapFilter_Triangle,
193 MipmapFilter_Kaiser,
207 MipmapFilter_Mitchell,
220 MipmapFilter_Min,
223 MipmapFilter_Max,
224 };
225
227 enum ResizeFilter
228 {
232 ResizeFilter_Box,
236 ResizeFilter_Triangle,
239 ResizeFilter_Kaiser,
242 ResizeFilter_Mitchell,
245 ResizeFilter_Min,
248 ResizeFilter_Max
249 };
250
269 enum RoundMode
270 {
271 RoundMode_None,
272 RoundMode_ToNextPowerOfTwo,
273 RoundMode_ToNearestPowerOfTwo,
274 RoundMode_ToPreviousPowerOfTwo,
275 };
276
278 enum AlphaMode
279 {
282 AlphaMode_None,
285 AlphaMode_Transparency,
290 AlphaMode_Premultiplied,
291 };
292
297 struct OutputHandler
298 {
300 virtual ~OutputHandler() {}
301
303 virtual void beginImage(int size, int width, int height, int depth, int face, int miplevel) = 0;
304
306 virtual bool writeData(const void * data, int size) = 0;
307
309 virtual void endImage() = 0;
310 };
311
316 enum Error
317 {
318 Error_None,
319 Error_Unknown = Error_None,
320 Error_InvalidInput,
321 Error_UnsupportedFeature,
322 Error_CudaError,
323 Error_FileOpen,
324 Error_FileWrite,
325 Error_UnsupportedOutputFormat,
326 Error_Messaging,
327 Error_OutOfHostMemory,
328 Error_OutOfDeviceMemory,
329 Error_OutputWrite,
330 Error_Count
331 };
332
334 NVTT_API const char* errorString(Error e);
335
337 struct ErrorHandler
338 {
340 virtual ~ErrorHandler() {}
341
343 virtual void error(Error e) = 0;
344 };
345
348 enum Severity
349 {
352 Severity_Info,
356 Severity_Warning,
360 Severity_Error,
361 Severity_Count
362 };
363
370 typedef void (*MessageCallback)(Severity severity, Error error, const char* message, const void* userData);
371
404 NVTT_API bool setMessageCallback(MessageCallback callback, const void* userData);
405
421 enum Container
422 {
423 Container_DDS,
424 Container_DDS10,
425 // Container_KTX, // Khronos Texture: http://www.khronos.org/opengles/sdk/tools/KTX/
426 // Container_VTF, // Valve Texture Format: http://developer.valvesoftware.com/wiki/Valve_Texture_Format
427 };
428
434 struct OutputOptions
435 {
436 NVTT_FORBID_COPY(OutputOptions)
437 NVTT_DECLARE_PIMPL(OutputOptions)
438
439 NVTT_API OutputOptions();
440 NVTT_API ~OutputOptions();
441
443 NVTT_API void reset();
444
447 NVTT_API void setFileName(const char * fileName);
448
450 NVTT_API void setFileHandle(void * fp);
451
453 NVTT_API void setOutputHandler(OutputHandler * outputHandler);
454
456 NVTT_API void setErrorHandler(ErrorHandler * errorHandler);
457
459 NVTT_API void setOutputHeader(bool outputHeader);
460
462 NVTT_API void setContainer(Container container);
463
467 NVTT_API void setUserVersion(int version);
468
474 NVTT_API void setSrgbFlag(bool b);
475 };
476
478 struct Context
479 {
480 NVTT_FORBID_COPY(Context)
481 NVTT_DECLARE_PIMPL(Context)
482
483
485 NVTT_API Context(bool enableCuda = true);
486 NVTT_API ~Context();
487
489 NVTT_API void enableCudaAcceleration(bool enable);
491 NVTT_API bool isCudaAccelerationEnabled() const;
492
496 NVTT_API bool outputHeader(const Surface & img, int mipmapCount, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const;
504 NVTT_API bool compress(const Surface & img, int face, int mipmap, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const;
519 NVTT_API int estimateSize(const Surface & img, int mipmapCount, const CompressionOptions & compressionOptions) const;
520
531 NVTT_API void quantize(Surface & tex, const CompressionOptions & compressionOptions) const;
532
537 NVTT_API bool outputHeader(const CubeSurface & cube, int mipmapCount, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const;
544 NVTT_API bool compress(const CubeSurface & cube, int mipmap, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const;
559 NVTT_API int estimateSize(const CubeSurface & cube, int mipmapCount, const CompressionOptions & compressionOptions) const;
560
564 NVTT_API bool outputHeader(TextureType type, int w, int h, int d, int mipmapCount, bool isNormalMap, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const;
575 NVTT_API bool compress(int w, int h, int d, int face, int mipmap, const float * rgba, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const;
592 NVTT_API int estimateSize(int w, int h, int d, int mipmapCount, const CompressionOptions & compressionOptions) const;
593
601 NVTT_API bool compress(const BatchList & lst, const CompressionOptions & compressionOptions) const;
602
606 NVTT_API void enableTiming(bool enable, int detailLevel = 1);
609 NVTT_API TimingContext* getTimingContext();
610
611 };
612
622 enum NormalTransform {
624 NormalTransform_Orthographic,
628 NormalTransform_Stereographic,
630 NormalTransform_Paraboloid,
632 NormalTransform_Quartic
633 //NormalTransform_DualParaboloid,
634 };
635
638 enum ToneMapper {
642 ToneMapper_Linear,
644 ToneMapper_Reinhard,
646 ToneMapper_Reindhart = ToneMapper_Reinhard,
648 ToneMapper_Halo,
650 ToneMapper_Lightmap,
651 };
652
696 // @@ It would be nice to add support for texture borders for correct resizing of tiled textures and constrained DXT compression.
697 struct Surface
698 {
701 NVTT_API Surface();
703 NVTT_API Surface(const Surface & img);
705 NVTT_API ~Surface();
706
708 NVTT_API void operator=(const Surface & img);
710 NVTT_API Surface clone() const;
711
713 NVTT_API void setWrapMode(WrapMode mode);
715 NVTT_API void setAlphaMode(AlphaMode alphaMode);
719 NVTT_API void setNormalMap(bool isNormalMap);
720
723 NVTT_API bool isNull() const;
725 NVTT_API int width() const;
727 NVTT_API int height() const;
729 NVTT_API int depth() const;
732 NVTT_API TextureType type() const;
734 NVTT_API WrapMode wrapMode() const;
736 NVTT_API AlphaMode alphaMode() const;
738 NVTT_API bool isNormalMap() const;
747 NVTT_API int countMipmaps() const;
756 NVTT_API int countMipmaps(int min_size) const;
764 NVTT_API float alphaTestCoverage(float alphaRef = 0.5, int alpha_channel = 3) const;
786 NVTT_API float average(int channel, int alpha_channel = -1, float gamma = 2.2f) const;
787
799 NVTT_API const float * data() const;
813 NVTT_API const float * channel(int i) const;
814
816 NVTT_API float * data();
818 NVTT_API float * channel(int i);
819
831 NVTT_API void histogram(int channel, float rangeMin, float rangeMax, int binCount, int * binPtr, TimingContext *tc = 0) const;
843 NVTT_API void range(int channel, float * rangeMin, float * rangeMax, int alpha_channel = -1, float alpha_ref = 0.f, TimingContext *tc = 0) const;
844
856 NVTT_API bool load(const char * fileName, bool * hasAlpha = 0, bool expectSigned = false, TimingContext *tc = 0);
868 NVTT_API bool loadFromMemory(const void * data, unsigned long long sizeInBytes, bool * hasAlpha = 0, bool expectSigned = false, TimingContext *tc = 0);
878 NVTT_API bool save(const char * fileName, bool hasAlpha = false, bool hdr = false, TimingContext *tc = 0) const;
885 NVTT_API bool setImage(int w, int h, int d, TimingContext *tc = 0);
897 NVTT_API bool setImage(InputFormat format, int w, int h, int d, const void * data, bool unsignedToSigned = false, TimingContext *tc = 0);
905 NVTT_API bool setImage(InputFormat format, int w, int h, int d, const void * r, const void * g, const void * b, const void * a, TimingContext *tc = 0);
907 NVTT_API bool setImage2D(Format format, int w, int h, const void * data, TimingContext *tc = 0);
913 NVTT_API bool setImage3D(Format format, int w, int h, int d, const void * data, TimingContext *tc = 0);
914
916 NVTT_API void resize(int w, int h, int d, ResizeFilter filter, TimingContext *tc = 0);
920 NVTT_API void resize(int w, int h, int d, ResizeFilter filter, float filterWidth, const float * params = 0, TimingContext *tc = 0);
923 NVTT_API void resize(int maxExtent, RoundMode mode, ResizeFilter filter, TimingContext *tc = 0);
926 NVTT_API void resize(int maxExtent, RoundMode mode, ResizeFilter filter, float filterWidth, const float * params = 0, TimingContext *tc = 0);
933 NVTT_API void resize_make_square(int maxExtent, RoundMode roundMode, ResizeFilter filter, TimingContext *tc = 0);
934
939 NVTT_API bool buildNextMipmap(MipmapFilter filter, int min_size = 1, TimingContext *tc = 0);
943 NVTT_API bool buildNextMipmap(MipmapFilter filter, float filterWidth, const float * params = 0, int min_size = 1, TimingContext *tc = 0);
950 NVTT_API bool buildNextMipmapSolidColor(const float * const color_components, TimingContext *tc = 0);
952 NVTT_API void canvasSize(int w, int h, int d, TimingContext *tc = 0);
958 NVTT_API bool canMakeNextMipmap(int min_size = 1);
959
966 NVTT_API void toLinear(float gamma, TimingContext *tc = 0);
973 NVTT_API void toGamma(float gamma, TimingContext *tc = 0);
976 NVTT_API void toLinear(int channel, float gamma, TimingContext *tc = 0);
979 NVTT_API void toGamma(int channel, float gamma, TimingContext *tc = 0);
991 NVTT_API void toSrgb(TimingContext *tc = 0);
1007 NVTT_API void toSrgbUnclamped(TimingContext *tc = 0);
1019 NVTT_API void toLinearFromSrgb(TimingContext *tc = 0);
1035 NVTT_API void toLinearFromSrgbUnclamped(TimingContext *tc = 0);
1051 NVTT_API void toXenonSrgb(TimingContext *tc = 0);
1068 NVTT_API void toLinearFromXenonSrgb(TimingContext *tc = 0);
1081 NVTT_API void transform(const float w0[4], const float w1[4], const float w2[4], const float w3[4], const float offset[4], TimingContext *tc = 0);
1090 NVTT_API void swizzle(int r, int g, int b, int a, TimingContext *tc = 0);
1092 NVTT_API void scaleBias(int channel, float scale, float bias, TimingContext *tc = 0);
1094 NVTT_API void clamp(int channel, float low = 0.0f, float high = 1.0f, TimingContext *tc = 0);
1101 NVTT_API void blend(float r, float g, float b, float a, float t, TimingContext *tc = 0);
1103 NVTT_API void premultiplyAlpha(TimingContext *tc = 0);
1110 NVTT_API void demultiplyAlpha(float epsilon = 1e-12f, TimingContext *tc = 0);
1121 NVTT_API void toGreyScale(float redScale, float greenScale, float blueScale, float alphaScale, TimingContext *tc = 0);
1123 NVTT_API void setBorder(float r, float g, float b, float a, TimingContext *tc = 0);
1125 NVTT_API void fill(float r, float g, float b, float a, TimingContext *tc = 0);
1132 NVTT_API void scaleAlphaToCoverage(float coverage, float alphaRef = 0.5f, int alpha_channel = 3, TimingContext *tc = 0);
1137 NVTT_API void toRGBM(float range = 1.0f, float threshold = 0.25f, TimingContext *tc = 0);
1144 NVTT_API void fromRGBM(float range = 1.0f, float threshold = 0.25f, TimingContext *tc = 0);
1151 NVTT_API void toLM(float range = 1.0f, float threshold = 0.0f, TimingContext *tc = 0);
1158 NVTT_API void toRGBE(int mantissaBits, int exponentBits, TimingContext *tc = 0);
1170 NVTT_API void fromRGBE(int mantissaBits, int exponentBits, TimingContext *tc = 0);
1183 NVTT_API void toYCoCg(TimingContext *tc = 0);
1199 NVTT_API void blockScaleCoCg(int bits = 5, float threshold = 0.0f, TimingContext *tc = 0);
1214 NVTT_API void fromYCoCg(TimingContext *tc = 0);
1223 NVTT_API void toLUVW(float range = 1.0f, TimingContext *tc = 0);
1227 NVTT_API void fromLUVW(float range = 1.0f, TimingContext *tc = 0);
1229 NVTT_API void abs(int channel, TimingContext *tc = 0);
1235 NVTT_API void convolve(int channel, int kernelSize, float * kernelData, TimingContext *tc = 0);
1237 NVTT_API void toLogScale(int channel, float base, TimingContext *tc = 0);
1239 NVTT_API void fromLogScale(int channel, float base, TimingContext *tc = 0);
1245 NVTT_API void setAtlasBorder(int w, int h, float r, float g, float b, float a, TimingContext *tc = 0);
1248 NVTT_API void toneMap(ToneMapper tm, float * parameters, TimingContext *tc = 0);
1249
1252 NVTT_API void binarize(int channel, float threshold, bool dither, TimingContext *tc = 0);
1260 NVTT_API void quantize(int channel, int bits, bool exactEndPoints, bool dither, TimingContext *tc = 0);
1261
1279 NVTT_API void toNormalMap(float sm, float medium, float big, float large, TimingContext *tc = 0);
1283 NVTT_API void normalizeNormalMap(TimingContext *tc = 0);
1287 NVTT_API void transformNormals(NormalTransform xform, TimingContext *tc = 0);
1291 NVTT_API void reconstructNormals(NormalTransform xform, TimingContext *tc = 0);
1309 NVTT_API void toCleanNormalMap(TimingContext *tc = 0);
1311 NVTT_API void packNormals(float scale = 0.5f, float bias = 0.5f, TimingContext *tc = 0);
1313 NVTT_API void expandNormals(float scale = 2.0f, float bias = -1.0f, TimingContext *tc = 0);
1317 NVTT_API Surface createToksvigMap(float power, TimingContext *tc = 0) const;
1320 NVTT_API Surface createCleanMap(TimingContext *tc = 0) const;
1321
1323 NVTT_API void flipX(TimingContext *tc = 0);
1325 NVTT_API void flipY(TimingContext *tc = 0);
1327 NVTT_API void flipZ(TimingContext *tc = 0);
1333 NVTT_API Surface createSubImage(int x0, int x1, int y0, int y1, int z0, int z1, TimingContext *tc = 0) const;
1334
1343 NVTT_API bool copyChannel(const Surface & srcImage, int srcChannel, TimingContext *tc = 0);
1352 NVTT_API bool copyChannel(const Surface & srcImage, int srcChannel, int dstChannel, TimingContext *tc = 0);
1361 NVTT_API bool addChannel(const Surface & img, int srcChannel, int dstChannel, float scale, TimingContext *tc = 0);
1374 NVTT_API bool copy(const Surface & src, int xsrc, int ysrc, int zsrc, int xsize, int ysize, int zsize, int xdst, int ydst, int zdst, TimingContext *tc = 0);
1375
1381 NVTT_API void ToGPU(TimingContext *tc = 0, bool performCopy = true);
1387 NVTT_API void ToCPU(TimingContext *tc = 0);
1390 NVTT_API const float * gpuData() const;
1396 NVTT_API float * gpuDataMutable();
1397
1398 //private:
1399 void detach();
1400
1401 struct Private;
1402 Private * m;
1403 };
1404
1407 struct SurfaceSet
1408 {
1409 NVTT_FORBID_COPY(SurfaceSet)
1410 NVTT_DECLARE_PIMPL(SurfaceSet)
1411
1412
1413 NVTT_API SurfaceSet();
1415 NVTT_API ~SurfaceSet();
1416
1418 NVTT_API TextureType GetTextureType();
1420 NVTT_API int GetFaceCount();
1422 NVTT_API int GetMipmapCount();
1424 NVTT_API int GetWidth();
1426 NVTT_API int GetHeight();
1428 NVTT_API int GetDepth();
1429
1431 NVTT_API Surface GetSurface(int faceId, int mipId, bool expectSigned = false);
1432
1434 NVTT_API void GetSurface(int faceId, int mipId, Surface& surface, bool expectSigned = false);
1435
1437 NVTT_API void reset();
1438
1447 NVTT_API bool loadDDS(const char * fileName, bool forcenormal = false);
1448
1449
1458 NVTT_API bool loadDDSFromMemory(const void * data, unsigned long long sizeInBytes, bool forcenormal = false);
1459
1461 NVTT_API bool saveImage(const char* fileName, int faceId, int mipId);
1462
1463 };
1464
1467 enum CubeLayout {
1477 CubeLayout_VerticalCross,
1486 CubeLayout_HorizontalCross,
1496 CubeLayout_Column,
1501 CubeLayout_Row,
1503 CubeLayout_LatitudeLongitude
1504 };
1505
1507 enum EdgeFixup {
1508 EdgeFixup_None,
1509 EdgeFixup_Stretch,
1510 EdgeFixup_Warp,
1511 EdgeFixup_Average,
1512 };
1513
1524 struct CubeSurface
1525 {
1527 NVTT_API CubeSurface();
1529 NVTT_API CubeSurface(const CubeSurface & img);
1531 NVTT_API ~CubeSurface();
1533 NVTT_API void operator=(const CubeSurface & img);
1534
1537 NVTT_API bool isNull() const;
1539 NVTT_API int edgeLength() const;
1546 NVTT_API int countMipmaps() const;
1547
1559 NVTT_API bool load(const char * fileName, int mipmap);
1571 NVTT_API bool loadFromMemory(const void * data, unsigned long long sizeInBytes, int mipmap);
1575 NVTT_API bool save(const char * fileName) const;
1576
1580 NVTT_API Surface & face(int face);
1584 NVTT_API const Surface & face(int face) const;
1585
1589 NVTT_API void fold(const Surface & img, CubeLayout layout);
1593 NVTT_API Surface unfold(CubeLayout layout) const;
1594
1595 // @@ Angular extent filtering.
1596
1597 // @@ Add resizing methods.
1598
1599 // @@ Add edge fixup methods.
1600
1608 NVTT_API float average(int channel) const;
1614 NVTT_API void range(int channel, float * minimum_ptr, float * maximum_ptr) const;
1616 NVTT_API void clamp(int channel, float low = 0.0f, float high = 1.0f);
1617
1618
1620 NVTT_API CubeSurface irradianceFilter(int size, EdgeFixup fixupMethod) const;
1632 NVTT_API CubeSurface cosinePowerFilter(int size, float cosinePower, EdgeFixup fixupMethod) const;
1634 NVTT_API CubeSurface fastResample(int size, EdgeFixup fixupMethod) const;
1635
1641 NVTT_API void toLinear(float gamma);
1647 NVTT_API void toGamma(float gamma);
1648
1649 //private:
1650 void detach();
1651
1652 struct Private;
1653 Private * m;
1654 };
1655
1662 struct BatchList
1663 {
1664 NVTT_FORBID_COPY(BatchList)
1665 NVTT_DECLARE_PIMPL(BatchList)
1666
1667
1668 NVTT_API BatchList();
1670 NVTT_API ~BatchList();
1672 NVTT_API void Clear();
1674 NVTT_API void Append(const Surface* pImg, int face, int mipmap, const OutputOptions* outputOptions);
1675
1677 NVTT_API unsigned GetSize() const;
1679 NVTT_API void GetItem(unsigned i, const Surface*& pImg, int& face, int& mipmap, const OutputOptions*& outputOptions) const;
1680
1681 };
1682
1683
1685 NVTT_API float rmsError(const Surface & reference, const Surface & img, TimingContext *tc = 0);
1687 NVTT_API float rmsAlphaError(const Surface & reference, const Surface & img, TimingContext *tc = 0);
1689 NVTT_API float cieLabError(const Surface & reference, const Surface & img, TimingContext *tc = 0);
1691 NVTT_API float angularError(const Surface & reference, const Surface & img, TimingContext *tc = 0);
1693 NVTT_API Surface diff(const Surface & reference, const Surface & img, float scale, TimingContext *tc = 0);
1694
1696 NVTT_API float rmsToneMappedError(const Surface & reference, const Surface & img, float exposure, TimingContext *tc = 0);
1697
1699 NVTT_API Surface histogram(const Surface & img, int width, int height, TimingContext *tc = 0);
1700
1702 NVTT_API Surface histogram(const Surface & img, float minRange, float maxRange, int width, int height, TimingContext *tc = 0);
1703
1705 NVTT_API void getTargetExtent(int * width, int * height, int * depth, int maxExtent, RoundMode roundMode, TextureType textureType, TimingContext *tc = 0);
1706
1708 NVTT_API int countMipmaps(int w, int h, int d, TimingContext *tc = 0);
1709
1721 struct TimingContext
1722 {
1728 NVTT_API TimingContext(int detailLevel = 1);
1730 NVTT_API ~TimingContext();
1731
1737 NVTT_API void SetDetailLevel(int detailLevel);
1738
1740 NVTT_API int GetRecordCount();
1749 NVTT_DEPRECATED_API void GetRecord(int i, char* description, double& seconds);
1762 NVTT_API size_t GetRecord(int i, char* outDescription, size_t outDescriptionSize, double& outSeconds);
1763
1769 NVTT_API void PrintRecords();
1770
1771 struct Private;
1772 Private * m;
1773 };
1774}
1775
1776
1777#endif
nvtt
Namespace for all public non-macro NVTT fields.
Definition nvtt.h:52
nvtt::WrapMode
WrapMode
Wrap modes. Specifies how to handle coordinates outside the typical image range.
Definition nvtt.h:133
nvtt::WrapMode_Mirror
@ WrapMode_Mirror
Definition nvtt.h:143
nvtt::WrapMode_Repeat
@ WrapMode_Repeat
Definition nvtt.h:139
nvtt::WrapMode_Clamp
@ WrapMode_Clamp
Definition nvtt.h:136
nvtt::version
NVTT_API unsigned int version()
Return the NVTT version number, as 10000*fork + 100*major + minor.
nvtt::TextureType
TextureType
Texture types. Specifies the dimensionality of a texture.
Definition nvtt.h:148
nvtt::AlphaMode
AlphaMode
Alpha mode.
Definition nvtt.h:279
nvtt::AlphaMode_Premultiplied
@ AlphaMode_Premultiplied
Definition nvtt.h:290
nvtt::AlphaMode_None
@ AlphaMode_None
Definition nvtt.h:282
nvtt::AlphaMode_Transparency
@ AlphaMode_Transparency
Definition nvtt.h:285
nvtt::MipmapFilter
MipmapFilter
Mipmap downsampling filters. Each of these can be customized using filterWidth and params when callin...
Definition nvtt.h:167
nvtt::MipmapFilter_Min
@ MipmapFilter_Min
Definition nvtt.h:220
nvtt::MipmapFilter_Triangle
@ MipmapFilter_Triangle
Definition nvtt.h:176
nvtt::MipmapFilter_Box
@ MipmapFilter_Box
Definition nvtt.h:172
nvtt::MipmapFilter_Max
@ MipmapFilter_Max
Definition nvtt.h:223
nvtt::MipmapFilter_Mitchell
@ MipmapFilter_Mitchell
Definition nvtt.h:207
nvtt::MipmapFilter_Kaiser
@ MipmapFilter_Kaiser
Definition nvtt.h:193
nvtt::errorString
NVTT_API const char * errorString(Error e)
Return string for the given error code.
nvtt::ToneMapper
ToneMapper
Tone mapping functions.
Definition nvtt.h:638
nvtt::ToneMapper_Reinhard
@ ToneMapper_Reinhard
Applies a Reinhard operator to each channel: c' = c / (c + 1).
Definition nvtt.h:644
nvtt::ToneMapper_Halo
@ ToneMapper_Halo
Applies an exponential tone mapper to each channel: c' = 1 - 2^(-c).
Definition nvtt.h:648
nvtt::ToneMapper_Lightmap
@ ToneMapper_Lightmap
Same as ToneMapper_Linear.
Definition nvtt.h:650
nvtt::ToneMapper_Reindhart
@ ToneMapper_Reindhart
Name for backwards compatibility.
Definition nvtt.h:646
nvtt::ToneMapper_Linear
@ ToneMapper_Linear
Definition nvtt.h:642
nvtt::MessageCallback
void(* MessageCallback)(Severity severity, Error error, const char *message, const void *userData)
Definition nvtt.h:370
nvtt::ResizeFilter
ResizeFilter
Texture resizing filters.
Definition nvtt.h:228
nvtt::ResizeFilter_Max
@ ResizeFilter_Max
Definition nvtt.h:248
nvtt::ResizeFilter_Kaiser
@ ResizeFilter_Kaiser
Definition nvtt.h:239
nvtt::ResizeFilter_Triangle
@ ResizeFilter_Triangle
Definition nvtt.h:236
nvtt::ResizeFilter_Box
@ ResizeFilter_Box
Definition nvtt.h:232
nvtt::ResizeFilter_Min
@ ResizeFilter_Min
Definition nvtt.h:245
nvtt::ResizeFilter_Mitchell
@ ResizeFilter_Mitchell
Definition nvtt.h:242
nvtt::NormalTransform
NormalTransform
Specifies a normal transformation, used to store 3D (x, y, z) normals in 2D (x, y).
Definition nvtt.h:622
nvtt::NormalTransform_Orthographic
@ NormalTransform_Orthographic
Reconstructs the z component using z = sqrt(1 - x^2 + y^2).
Definition nvtt.h:624
nvtt::NormalTransform_Paraboloid
@ NormalTransform_Paraboloid
Reconstructed using normalize(x, y, 1 - min(x^2 + y^2, 1)).
Definition nvtt.h:630
nvtt::NormalTransform_Quartic
@ NormalTransform_Quartic
Reconstructed using normalize(x, y, (1-x^2)(1-y^2)).
Definition nvtt.h:632
nvtt::NormalTransform_Stereographic
@ NormalTransform_Stereographic
Definition nvtt.h:628
nvtt::CubeLayout
CubeLayout
Specifies how to fold or unfold a cube map from or to a 2D texture.
Definition nvtt.h:1467
nvtt::CubeLayout_Column
@ CubeLayout_Column
Definition nvtt.h:1496
nvtt::CubeLayout_Row
@ CubeLayout_Row
Definition nvtt.h:1501
nvtt::CubeLayout_HorizontalCross
@ CubeLayout_HorizontalCross
Definition nvtt.h:1486
nvtt::CubeLayout_VerticalCross
@ CubeLayout_VerticalCross
Definition nvtt.h:1477
nvtt::CubeLayout_LatitudeLongitude
@ CubeLayout_LatitudeLongitude
Same as CubeLayout_VerticalCross.
Definition nvtt.h:1503
nvtt::Severity
Severity
Message severity.
Definition nvtt.h:349
nvtt::Severity_Error
@ Severity_Error
Definition nvtt.h:360
nvtt::Severity_Warning
@ Severity_Warning
Definition nvtt.h:356
nvtt::Severity_Info
@ Severity_Info
Definition nvtt.h:352
nvtt::Quality
Quality
Quality modes.
Definition nvtt_lowlevel.h:329
nvtt::RoundMode
RoundMode
Extents rounding mode.
Definition nvtt.h:270
nvtt::RoundMode_ToNearestPowerOfTwo
@ RoundMode_ToNearestPowerOfTwo
Each extent is rounded either up or down to the nearest power of two.
Definition nvtt.h:273
nvtt::RoundMode_ToNextPowerOfTwo
@ RoundMode_ToNextPowerOfTwo
Each extent is rounded up to the next power of two.
Definition nvtt.h:272
nvtt::RoundMode_ToPreviousPowerOfTwo
@ RoundMode_ToPreviousPowerOfTwo
Each element is rounded down to the next power of two.
Definition nvtt.h:274
nvtt::RoundMode_None
@ RoundMode_None
Each extent is left as-is.
Definition nvtt.h:271
nvtt::Format
Format
Supported block-compression formats, including compressor variants.
Definition nvtt_lowlevel.h:218
nvtt::InputFormat
InputFormat
Input formats. Used when creating an nvtt::Surface from an RGB/RGBA array.
Definition nvtt.h:156
nvtt::InputFormat_BGRA_8SB
@ InputFormat_BGRA_8SB
[-127, 127] 8 bit int
Definition nvtt.h:158
nvtt::InputFormat_RGBA_16F
@ InputFormat_RGBA_16F
16 bit floating point.
Definition nvtt.h:159
nvtt::InputFormat_RGBA_32F
@ InputFormat_RGBA_32F
32 bit floating point.
Definition nvtt.h:160
nvtt::InputFormat_R_32F
@ InputFormat_R_32F
Single channel 32 bit floating point.
Definition nvtt.h:161
nvtt::InputFormat_BGRA_8UB
@ InputFormat_BGRA_8UB
[0, 255] 8 bit uint
Definition nvtt.h:157
nvtt::setMessageCallback
NVTT_API bool setMessageCallback(MessageCallback callback, const void *userData)
nvtt::PixelType
PixelType
Pixel value types.
Definition nvtt_lowlevel.h:302
nvtt::EdgeFixup
EdgeFixup
Use EdgeFixup_None if unsure; this affects how certain cube surface processing algorithms work.
Definition nvtt.h:1507
nvtt::EdgeFixup_Average
@ EdgeFixup_Average
Currently unimplemented.
Definition nvtt.h:1511
nvtt::EdgeFixup_Warp
@ EdgeFixup_Warp
Applies a cubic warp to each face's coordinate system in cosinePowerFilter() and fastResample(),...
Definition nvtt.h:1510
nvtt::EdgeFixup_Stretch
@ EdgeFixup_Stretch
Slightly stretches and shifts the coordinate systems cosinePowerFilter() and fastResample() use.
Definition nvtt.h:1509
nvtt::EdgeFixup_None
@ EdgeFixup_None
No effect.
Definition nvtt.h:1508
nvtt::Error
Error
Error codes.
Definition nvtt.h:317
nvtt::Error_FileOpen
@ Error_FileOpen
I/O error attempting to open the given file.
Definition nvtt.h:323
nvtt::Error_UnsupportedFeature
@ Error_UnsupportedFeature
Unsupported feature.
Definition nvtt.h:321
nvtt::Error_FileWrite
@ Error_FileWrite
I/O error attempting to write to the given file.
Definition nvtt.h:324
nvtt::Error_Messaging
@ Error_Messaging
Internal error while invoking the message callback.
Definition nvtt.h:326
nvtt::Error_CudaError
@ Error_CudaError
CUDA reported an error during an operation.
Definition nvtt.h:322
nvtt::Error_None
@ Error_None
No error.
Definition nvtt.h:318
nvtt::Error_InvalidInput
@ Error_InvalidInput
The input to the function was invalid (for instance, a negative size).
Definition nvtt.h:320
nvtt::Error_UnsupportedOutputFormat
@ Error_UnsupportedOutputFormat
The chosen container does not support the requested format (for instance, attempting to store BC7 dat...
Definition nvtt.h:325
nvtt::Error_OutputWrite
@ Error_OutputWrite
OutputOptions::writeData() returned false.
Definition nvtt.h:329
nvtt::Error_OutOfDeviceMemory
@ Error_OutOfDeviceMemory
Out of device memory (allocating a GPU-side buffer failed).
Definition nvtt.h:328
nvtt::Error_Unknown
@ Error_Unknown
Alias used before NVTT 3.2 for Error_None.
Definition nvtt.h:319
nvtt::Error_OutOfHostMemory
@ Error_OutOfHostMemory
Out of host memory (allocating a CPU-side buffer failed).
Definition nvtt.h:327
nvtt::Container
Container
Container type for encoded data.
Definition nvtt.h:422
nvtt::Container_DDS
@ Container_DDS
DDS without the DX10 header extension. Compatible with legacy readers, but doesn't support BC6 or BC7...
Definition nvtt.h:423
nvtt::Container_DDS10
@ Container_DDS10
DDS without the DX10 header. Supports BC6 and BC7, but may be unreadable by legacy readers.
Definition nvtt.h:424
NVTT_FORBID_COPY
#define NVTT_FORBID_COPY(Class)
Prevents a class from being copied.
Definition nvtt.h:37
NVTT_DECLARE_PIMPL
#define NVTT_DECLARE_PIMPL(Class)
Hides the members of the implementation of the class behind a Private structure.
Definition nvtt.h:45
nvtt_lowlevel.h
NVTT_DEPRECATED_API
#define NVTT_DEPRECATED_API
These functions are accessible via the NVTT DLL, but there are better replacements for them,...
Definition nvtt_lowlevel.h:60
NVTT_API
#define NVTT_API
Functions with this macro are accessible via the NVTT DLL.
Definition nvtt_lowlevel.h:56
nvtt::BatchList
Structure defining a list of inputs to be compressed.
Definition nvtt.h:1663
nvtt::CompressionOptions
Compression options. This class describes the desired compression format and other compression settin...
Definition nvtt.h:64
nvtt::CompressionOptions::setPixelType
NVTT_API void setPixelType(PixelType pixelType)
Set pixel type.
nvtt::CompressionOptions::reset
NVTT_API void reset()
Set default compression options.
nvtt::CompressionOptions::setQuality
NVTT_API void setQuality(Quality quality)
Set compression quality settings.
nvtt::CompressionOptions::setColorWeights
NVTT_API void setColorWeights(float red, float green, float blue, float alpha=1.0f)
Set the weights of each color channel used to measure compression error.
nvtt::CompressionOptions::d3d9Format
NVTT_API unsigned int d3d9Format() const
Translates to a D3D format.
nvtt::CompressionOptions::setQuantization
NVTT_API void setQuantization(bool colorDithering, bool alphaDithering, bool binaryAlpha, int alphaThreshold=127)
Set quantization options.
nvtt::CompressionOptions::setPitchAlignment
NVTT_API void setPitchAlignment(int pitchAlignment)
Set pitch alignment in bytes.
nvtt::CompressionOptions::setFormat
NVTT_API void setFormat(Format format)
Set desired compression format.
nvtt::CompressionOptions::setPixelFormat
NVTT_API void setPixelFormat(unsigned int bitcount, unsigned int rmask, unsigned int gmask, unsigned int bmask, unsigned int amask)
Describes an RGB/RGBA format using 32-bit masks per channel.
nvtt::Context
Compression context.
Definition nvtt.h:479
nvtt::CubeSurface
A CubeSurface is one level of a cube map texture.
Definition nvtt.h:1525
nvtt::CubeSurface::edgeLength
NVTT_API int edgeLength() const
Returns the edge length of any of the faces.
nvtt::CubeSurface::~CubeSurface
NVTT_API ~CubeSurface()
Destructor.
nvtt::CubeSurface::fastResample
NVTT_API CubeSurface fastResample(int size, EdgeFixup fixupMethod) const
Produces a resized version of this CubeSurface using nearest-neighbor sampling.
nvtt::CubeSurface::unfold
NVTT_API Surface unfold(CubeLayout layout) const
Creates a Surface containing an unfolded/flattened representation of the cube surface.
nvtt::CubeSurface::cosinePowerFilter
NVTT_API CubeSurface cosinePowerFilter(int size, float cosinePower, EdgeFixup fixupMethod) const
Spherically convolves this CubeSurface with a max(0.0f, cos(theta))^cosinePower kernel,...
nvtt::CubeSurface::face
NVTT_API Surface & face(int face)
Get a non-const reference to the surface for the given face.
nvtt::CubeSurface::face
NVTT_API const Surface & face(int face) const
Get a const reference to the surface for the given face.
nvtt::CubeSurface::countMipmaps
NVTT_API int countMipmaps() const
Returns the number of mips that would be in a full mipmap chain starting with this CubeSurface.
nvtt::CubeSurface::fold
NVTT_API void fold(const Surface &img, CubeLayout layout)
Sets this CubeSurface from a 2D unfolded surface in img.
nvtt::CubeSurface::CubeSurface
NVTT_API CubeSurface(const CubeSurface &img)
Copy constructor.
nvtt::CubeSurface::average
NVTT_API float average(int channel) const
Computes an average value for the given channel over the entire sphere.
nvtt::CubeSurface::irradianceFilter
NVTT_API CubeSurface irradianceFilter(int size, EdgeFixup fixupMethod) const
Unimplemented; returns a null CubeSurface.
nvtt::CubeSurface::save
NVTT_API bool save(const char *fileName) const
Save a cube map to a DDS file in memory.
nvtt::CubeSurface::clamp
NVTT_API void clamp(int channel, float low=0.0f, float high=1.0f)
Clamps values in the given channel to the range [low, high].
nvtt::CubeSurface::CubeSurface
NVTT_API CubeSurface()
Creates a null CubeSurface.
nvtt::CubeSurface::toGamma
NVTT_API void toGamma(float gamma)
Raises channels 0...2 to the power 1/gamma.
nvtt::CubeSurface::loadFromMemory
NVTT_API bool loadFromMemory(const void *data, unsigned long long sizeInBytes, int mipmap)
Load a cube map from a DDS file in memory.
nvtt::CubeSurface::load
NVTT_API bool load(const char *fileName, int mipmap)
Load a cube map from a DDS file.
nvtt::CubeSurface::range
NVTT_API void range(int channel, float *minimum_ptr, float *maximum_ptr) const
Sets *minimum_ptr and *maximum_ptr to the minimum and maximum values in the given channel.
nvtt::CubeSurface::operator=
NVTT_API void operator=(const CubeSurface &img)
Assignment operator.
nvtt::CubeSurface::isNull
NVTT_API bool isNull() const
Returns if this CubeSurface is null (i.e. has no underlying data, or all faces have size 0x0).
nvtt::CubeSurface::toLinear
NVTT_API void toLinear(float gamma)
Raises channels 0...2 to the power gamma.
nvtt::ErrorHandler
Inheritable interface for handling errors.
Definition nvtt.h:338
nvtt::ErrorHandler::error
virtual void error(Error e)=0
Called to signal an error.
nvtt::ErrorHandler::~ErrorHandler
virtual ~ErrorHandler()
Destructor.
Definition nvtt.h:340
nvtt::OutputHandler
Inheritable interface for outputting data.
Definition nvtt.h:298
nvtt::OutputHandler::~OutputHandler
virtual ~OutputHandler()
Destructor.
Definition nvtt.h:300
nvtt::OutputHandler::endImage
virtual void endImage()=0
Indicate the end of the compressed image. (New in NVTT 2.1)
nvtt::OutputHandler::beginImage
virtual void beginImage(int size, int width, int height, int depth, int face, int miplevel)=0
Indicate the start of a new compressed image that's part of the final texture.
nvtt::OutputHandler::writeData
virtual bool writeData(const void *data, int size)=0
Output data. Compressed data is output as soon as it's generated to minimize memory allocations.
nvtt::OutputOptions
Output Options.
Definition nvtt.h:435
nvtt::OutputOptions::reset
NVTT_API void reset()
Set default options.
nvtt::OutputOptions::setFileName
NVTT_API void setFileName(const char *fileName)
nvtt::OutputOptions::setContainer
NVTT_API void setContainer(Container container)
Set container. Defaults to Container_DDS.
nvtt::OutputOptions::setErrorHandler
NVTT_API void setErrorHandler(ErrorHandler *errorHandler)
Set error handler.
nvtt::OutputOptions::setFileHandle
NVTT_API void setFileHandle(void *fp)
Set output file handle.
nvtt::OutputOptions::setUserVersion
NVTT_API void setUserVersion(int version)
nvtt::OutputOptions::setOutputHandler
NVTT_API void setOutputHandler(OutputHandler *outputHandler)
Set output handler.
nvtt::OutputOptions::setSrgbFlag
NVTT_API void setSrgbFlag(bool b)
nvtt::OutputOptions::setOutputHeader
NVTT_API void setOutputHeader(bool outputHeader)
Set output header. Defaults to true.
nvtt::Surface
A surface is one level of a 2D or 3D texture.
Definition nvtt.h:698
nvtt::Surface::resize
NVTT_API void resize(int w, int h, int d, ResizeFilter filter, float filterWidth, const float *params=0, TimingContext *tc=0)
nvtt::Surface::channel
NVTT_API float * channel(int i)
Returns a pointer that can be used to modify channel i's CPU data. See channel(int) const.
nvtt::Surface::setAtlasBorder
NVTT_API void setAtlasBorder(int w, int h, float r, float g, float b, float a, TimingContext *tc=0)
Draws borders of a given color around each w x h tile contained within the surface,...
nvtt::Surface::fromYCoCg
NVTT_API void fromYCoCg(TimingContext *tc=0)
Converts from (Co, Cg, scale, Y) colors to (r, g, b, 1) colors.
nvtt::Surface::height
NVTT_API int height() const
Returns the height (Y size) of the surface.
nvtt::Surface::operator=
NVTT_API void operator=(const Surface &img)
Assignment operator.
nvtt::Surface::blend
NVTT_API void blend(float r, float g, float b, float a, float t, TimingContext *tc=0)
Interpolates all texels between their current color and a constant color (r, g, b,...
nvtt::Surface::createToksvigMap
NVTT_API Surface createToksvigMap(float power, TimingContext *tc=0) const
Unimplemented. This would equivalent to mipmapping a normal map and then measuring how much mipmappin...
nvtt::Surface::save
NVTT_API bool save(const char *fileName, bool hasAlpha=false, bool hdr=false, TimingContext *tc=0) const
Saves texture data to file.
nvtt::Surface::toYCoCg
NVTT_API void toYCoCg(TimingContext *tc=0)
Converts from (r, g, b, -) colors to (Co, Cg, 1, Y) colors.
nvtt::Surface::toSrgb
NVTT_API void toSrgb(TimingContext *tc=0)
Applies the linear-to-sRGB transfer function to channels 0...2.
nvtt::Surface::setWrapMode
NVTT_API void setWrapMode(WrapMode mode)
Set the Surface's wrap mode. See WrapMode for details.
nvtt::Surface::createSubImage
NVTT_API Surface createSubImage(int x0, int x1, int y0, int y1, int z0, int z1, TimingContext *tc=0) const
Creates a new surface from the range of pixels from x = x0 to x1, y = y0 to y1, and z = z0 to z1.
nvtt::Surface::toLM
NVTT_API void toLM(float range=1.0f, float threshold=0.0f, TimingContext *tc=0)
Stores luminance-only values in a two-channel way. Maybe consider BC4 compression instead.
nvtt::Surface::alphaMode
NVTT_API AlphaMode alphaMode() const
Returns the alpha mode of the surface. See setAlphaMode()
nvtt::Surface::flipX
NVTT_API void flipX(TimingContext *tc=0)
Flips the surface along the X axis.
nvtt::Surface::setImage3D
NVTT_API bool setImage3D(Format format, int w, int h, int d, const void *data, TimingContext *tc=0)
Set surface values from an encoded data source.
nvtt::Surface::toLinearFromXenonSrgb
NVTT_API void toLinearFromXenonSrgb(TimingContext *tc=0)
Converts colors in channels 0...2 from the Xenon sRGB piecewise linear sRGB approximation to linear.
nvtt::Surface::convolve
NVTT_API void convolve(int channel, int kernelSize, float *kernelData, TimingContext *tc=0)
Convolves a channel with a kernel.
nvtt::Surface::flipY
NVTT_API void flipY(TimingContext *tc=0)
Flips the surface along the Y axis.
nvtt::Surface::normalizeNormalMap
NVTT_API void normalizeNormalMap(TimingContext *tc=0)
Renormalizes the elements of a signed normal map, replacing (r, g, b) with normalize(r,...
nvtt::Surface::histogram
NVTT_API void histogram(int channel, float rangeMin, float rangeMax, int binCount, int *binPtr, TimingContext *tc=0) const
Stores a histogram of channel values between rangeMin and rangeMax into binPtr[0.....
nvtt::Surface::setNormalMap
NVTT_API void setNormalMap(bool isNormalMap)
Set whether the Surface represents a normal map. This can be accessed using isNormalMap(),...
nvtt::Surface::fromRGBM
NVTT_API void fromRGBM(float range=1.0f, float threshold=0.25f, TimingContext *tc=0)
Produces HDR (r, g, b, 1) values from an LDR (red, green, blue, magnitude) storage method.
nvtt::Surface::alphaTestCoverage
NVTT_API float alphaTestCoverage(float alphaRef=0.5, int alpha_channel=3) const
Returns the approximate fraction (0 to 1) of the image with an alpha value greater than alphaRef.
nvtt::Surface::isNull
NVTT_API bool isNull() const
Returns if the surface is null (i.e. refers to nothing, such as if it was just created using Surface(...
nvtt::Surface::canvasSize
NVTT_API void canvasSize(int w, int h, int d, TimingContext *tc=0)
Crops or expands this surface from the (0,0,0) corner, with any new values cleared to 0.
nvtt::Surface::data
NVTT_API const float * data() const
Returns a const pointer to the surface's CPU data.
nvtt::Surface::expandNormals
NVTT_API void expandNormals(float scale=2.0f, float bias=-1.0f, TimingContext *tc=0)
Expands packed normals in [0, 1] to signed normals in [-1, 1] using (r, g, b, a) |-> (2r-1,...
nvtt::Surface::toneMap
NVTT_API void toneMap(ToneMapper tm, float *parameters, TimingContext *tc=0)
Applies an HDR-to-LDR tone mapper.
nvtt::Surface::fromLUVW
NVTT_API void fromLUVW(float range=1.0f, TimingContext *tc=0)
Converts from toLUVW()'s color space to RGB colors.
nvtt::Surface::channel
NVTT_API const float * channel(int i) const
Returns a const pointer to channel i's CPU data.
nvtt::Surface::addChannel
NVTT_API bool addChannel(const Surface &img, int srcChannel, int dstChannel, float scale, TimingContext *tc=0)
Add channel srcChannel of img, multiplied by scale, to dstChannel of this surface.
nvtt::Surface::binarize
NVTT_API void binarize(int channel, float threshold, bool dither, TimingContext *tc=0)
Sets values in the given channel to either 1 or 0 depending on if they're greater than the threshold,...
nvtt::Surface::setImage2D
NVTT_API bool setImage2D(Format format, int w, int h, const void *data, TimingContext *tc=0)
Set 2D surface values from an encoded data source. Same as setImage3D() with d=1.
nvtt::Surface::premultiplyAlpha
NVTT_API void premultiplyAlpha(TimingContext *tc=0)
Converts to premultiplied alpha, replacing (r, g, b, a) with (ar, ag, ab, a).
nvtt::Surface::buildNextMipmapSolidColor
NVTT_API bool buildNextMipmapSolidColor(const float *const color_components, TimingContext *tc=0)
Replaces this surface with a surface the size of the next mip in a mip chain (half the width and heig...
nvtt::Surface::createCleanMap
NVTT_API Surface createCleanMap(TimingContext *tc=0) const
Unimplemented. Currently returns a null surface.
nvtt::Surface::copyChannel
NVTT_API bool copyChannel(const Surface &srcImage, int srcChannel, TimingContext *tc=0)
Copies channel srcChannel from srcImage to srcChannel of this surface.
nvtt::Surface::ToCPU
NVTT_API void ToCPU(TimingContext *tc=0)
Makes succeeding operations work on the CPU buffer.
nvtt::Surface::setImage
NVTT_API bool setImage(int w, int h, int d, TimingContext *tc=0)
Sets this surface to a new w x h x d uninitialized image.
nvtt::Surface::toLinear
NVTT_API void toLinear(float gamma, TimingContext *tc=0)
Raises channels 0...2 to the power gamma.
nvtt::Surface::isNormalMap
NVTT_API bool isNormalMap() const
Returns whether the image represents a normal map. See setNormalMap()
nvtt::Surface::~Surface
NVTT_API ~Surface()
Destructor.
nvtt::Surface::setImage
NVTT_API bool setImage(InputFormat format, int w, int h, int d, const void *r, const void *g, const void *b, const void *a, TimingContext *tc=0)
Sets this surface given uncompressed input data, with different pointers for each channel.
nvtt::Surface::toGamma
NVTT_API void toGamma(float gamma, TimingContext *tc=0)
Raises channels 0...2 to the power 1/gamma.
nvtt::Surface::depth
NVTT_API int depth() const
Returns the depth (Z size) of the surface. 1 for 2D surfaces.
nvtt::Surface::type
NVTT_API TextureType type() const
Returns the dimensionality of the surface. This is set for instance by setImage().
nvtt::Surface::resize
NVTT_API void resize(int maxExtent, RoundMode mode, ResizeFilter filter, float filterWidth, const float *params=0, TimingContext *tc=0)
Resizes this surface so that its largest side has length maxExtent, subject to a rounding mode,...
nvtt::Surface::swizzle
NVTT_API void swizzle(int r, int g, int b, int a, TimingContext *tc=0)
Swizzles the channels of the surface.
nvtt::Surface::load
NVTT_API bool load(const char *fileName, bool *hasAlpha=0, bool expectSigned=false, TimingContext *tc=0)
Loads texture data from a file.
nvtt::Surface::toLogScale
NVTT_API void toLogScale(int channel, float base, TimingContext *tc=0)
Replaces all values with their log with the given base.
nvtt::Surface::abs
NVTT_API void abs(int channel, TimingContext *tc=0)
Replaces all colors by their absolute value.
nvtt::Surface::clone
NVTT_API Surface clone() const
Creates a deep copy of this Surface, with its own internal data. (New in NVTT 3.1)
nvtt::Surface::loadFromMemory
NVTT_API bool loadFromMemory(const void *data, unsigned long long sizeInBytes, bool *hasAlpha=0, bool expectSigned=false, TimingContext *tc=0)
Variant of load() that reads from memory instead of a file.
nvtt::Surface::flipZ
NVTT_API void flipZ(TimingContext *tc=0)
Flips the surface along the Z axis.
nvtt::Surface::toXenonSrgb
NVTT_API void toXenonSrgb(TimingContext *tc=0)
Converts colors in channels 0...2 from linear to a piecewise linear sRGB approximation.
nvtt::Surface::toLinearFromSrgbUnclamped
NVTT_API void toLinearFromSrgbUnclamped(TimingContext *tc=0)
Applies the sRGB-to-linear transfer function to channels 0...2, but does not clamp output to [0,...
nvtt::Surface::copyChannel
NVTT_API bool copyChannel(const Surface &srcImage, int srcChannel, int dstChannel, TimingContext *tc=0)
Copies channel srcChannel from srcImage to dstChannel of this surface.
nvtt::Surface::toLinearFromSrgb
NVTT_API void toLinearFromSrgb(TimingContext *tc=0)
Applies the sRGB-to-linear transfer function to channels 0...2.
nvtt::Surface::gpuData
NVTT_API const float * gpuData() const
Get a CUDA pointer to const image data on the GPU, using the same layout as data()....
nvtt::Surface::countMipmaps
NVTT_API int countMipmaps(int min_size) const
Returns the number of mipmaps in a mipmap chain, stopping when canMakeNextMipmap() returns false.
nvtt::Surface::fromLogScale
NVTT_API void fromLogScale(int channel, float base, TimingContext *tc=0)
Inverts toLogScale() by replacing all values x with base^x.
nvtt::Surface::toLinear
NVTT_API void toLinear(int channel, float gamma, TimingContext *tc=0)
Raises the given channel to the power gamma.
nvtt::Surface::transform
NVTT_API void transform(const float w0[4], const float w1[4], const float w2[4], const float w3[4], const float offset[4], TimingContext *tc=0)
Applies a 4x4 affine transformation to the values in channels 0...3.
nvtt::Surface::demultiplyAlpha
NVTT_API void demultiplyAlpha(float epsilon=1e-12f, TimingContext *tc=0)
Converts from premultiplied to unpremultiplied alpha, with special handling around zero alpha values.
nvtt::Surface::countMipmaps
NVTT_API int countMipmaps() const
Returns the number of mipmaps in a full mipmap chain. Each mip is half the size of the previous,...
nvtt::Surface::fill
NVTT_API void fill(float r, float g, float b, float a, TimingContext *tc=0)
Sets all texels in the surface to a solid color.
nvtt::Surface::Surface
NVTT_API Surface()
Creates an empty surface. All data will be null until a setImage() function is called.
nvtt::Surface::resize
NVTT_API void resize(int w, int h, int d, ResizeFilter filter, TimingContext *tc=0)
Resizes this surface to have size w x h x d using a given filter.
nvtt::Surface::transformNormals
NVTT_API void transformNormals(NormalTransform xform, TimingContext *tc=0)
Applies a 3D->2D normal transformation, setting the z (blue) channel to 0.
nvtt::Surface::toLUVW
NVTT_API void toLUVW(float range=1.0f, TimingContext *tc=0)
Converts from RGB colors to a (U, V, W, L) color space, much like RGBM.
nvtt::Surface::setImage
NVTT_API bool setImage(InputFormat format, int w, int h, int d, const void *data, bool unsignedToSigned=false, TimingContext *tc=0)
Sets this surface given uncompressed input data.
nvtt::Surface::toRGBE
NVTT_API void toRGBE(int mantissaBits, int exponentBits, TimingContext *tc=0)
Produces a shared-exponent Red, Green, Blue, Exponent encoding of the HDR RGB channels,...
nvtt::Surface::Surface
NVTT_API Surface(const Surface &img)
Copy constructor.
nvtt::Surface::width
NVTT_API int width() const
Returns the width (X size) of the surface.
nvtt::Surface::buildNextMipmap
NVTT_API bool buildNextMipmap(MipmapFilter filter, int min_size=1, TimingContext *tc=0)
Resizes this surface to create the next mip in a mipmap chain.
nvtt::Surface::toNormalMap
NVTT_API void toNormalMap(float sm, float medium, float big, float large, TimingContext *tc=0)
Sets the RGB channels to a normal map generated by interpreting the alpha channel as a heightmap,...
nvtt::Surface::ToGPU
NVTT_API void ToGPU(TimingContext *tc=0, bool performCopy=true)
Makes succeeding operations work on the GPU buffer.
nvtt::Surface::scaleBias
NVTT_API void scaleBias(int channel, float scale, float bias, TimingContext *tc=0)
Applies a scale and bias to the given channel. Each value x is replaced by x * scale + bias.
nvtt::Surface::resize
NVTT_API void resize(int maxExtent, RoundMode mode, ResizeFilter filter, TimingContext *tc=0)
Resizes this surface so that its largest side has length maxExtent, subject to a rounding mode.
nvtt::Surface::fromRGBE
NVTT_API void fromRGBE(int mantissaBits, int exponentBits, TimingContext *tc=0)
Produces HDR (r, g, b, 1) values from an LDR (red, green, blue, exponent) storage method.
nvtt::Surface::data
NVTT_API float * data()
Returns a pointer that can be used to modify the surface's CPU data. See data() const.
nvtt::Surface::wrapMode
NVTT_API WrapMode wrapMode() const
Returns the wrap mode of the surface. See setWrapMode()
nvtt::Surface::reconstructNormals
NVTT_API void reconstructNormals(NormalTransform xform, TimingContext *tc=0)
Reconstructs 3D normals from 2D transformed normals.
nvtt::Surface::quantize
NVTT_API void quantize(int channel, int bits, bool exactEndPoints, bool dither, TimingContext *tc=0)
Quantizes this channel to a particular number of bits, with optional dithering.
nvtt::Surface::setBorder
NVTT_API void setBorder(float r, float g, float b, float a, TimingContext *tc=0)
Sets all texels on the border of the surface to a solid color.
nvtt::Surface::toGreyScale
NVTT_API void toGreyScale(float redScale, float greenScale, float blueScale, float alphaScale, TimingContext *tc=0)
Sets channels 0...3 to the result of converting to grayscale, with customizable channel weights.
nvtt::Surface::clamp
NVTT_API void clamp(int channel, float low=0.0f, float high=1.0f, TimingContext *tc=0)
Clamps all values in the channel to the range [low, high].
nvtt::Surface::gpuDataMutable
NVTT_API float * gpuDataMutable()
Get a CUDA pointer to non-const image data on the GPU, using the same layout as data()....
nvtt::Surface::toRGBM
NVTT_API void toRGBM(float range=1.0f, float threshold=0.25f, TimingContext *tc=0)
Produces an LDR Red, Green, Blue, Magnitude encoding of the HDR RGB channels.
nvtt::Surface::setAlphaMode
NVTT_API void setAlphaMode(AlphaMode alphaMode)
Set the Surface's alpha mode. See AlphaMode for details.
nvtt::Surface::average
NVTT_API float average(int channel, int alpha_channel=-1, float gamma=2.2f) const
Computes the average of a channel, possibly with alpha or with a gamma transfer function.
nvtt::Surface::packNormals
NVTT_API void packNormals(float scale=0.5f, float bias=0.5f, TimingContext *tc=0)
Packs signed normals in [-1, 1] to an unsigned range [0, 1], using (r, g, b, a) |-> (r/2+1/2,...
nvtt::Surface::canMakeNextMipmap
NVTT_API bool canMakeNextMipmap(int min_size=1)
Returns whether a the surface would have a next mip in a mip chain with minimum size `min_size.
nvtt::Surface::toGamma
NVTT_API void toGamma(int channel, float gamma, TimingContext *tc=0)
Raises the given channel to the power 1/gamma.
nvtt::Surface::resize_make_square
NVTT_API void resize_make_square(int maxExtent, RoundMode roundMode, ResizeFilter filter, TimingContext *tc=0)
Resizes this surface so that its longest side has length maxExtent and the result is square or cubica...
nvtt::Surface::buildNextMipmap
NVTT_API bool buildNextMipmap(MipmapFilter filter, float filterWidth, const float *params=0, int min_size=1, TimingContext *tc=0)
Version of buildNextMipmap(MipmapFilter, int, TimingContext*) with customizable parameters.
nvtt::Surface::copy
NVTT_API bool copy(const Surface &src, int xsrc, int ysrc, int zsrc, int xsize, int ysize, int zsize, int xdst, int ydst, int zdst, TimingContext *tc=0)
Copies all channels of a rectangle from src to this surface.
nvtt::Surface::range
NVTT_API void range(int channel, float *rangeMin, float *rangeMax, int alpha_channel=-1, float alpha_ref=0.f, TimingContext *tc=0) const
Sets *rangeMin and *rangeMax to the range of values in the channel, possibly using alpha testing.
nvtt::Surface::blockScaleCoCg
NVTT_API void blockScaleCoCg(int bits=5, float threshold=0.0f, TimingContext *tc=0)
Stores per-block YCoCg scaling information for potentially better 4-channel compression of YCoCg data...
nvtt::Surface::toSrgbUnclamped
NVTT_API void toSrgbUnclamped(TimingContext *tc=0)
Applies the linear-to-sRGB transfer function to channels 0...2, but does not clamp output to [0,...
nvtt::Surface::scaleAlphaToCoverage
NVTT_API void scaleAlphaToCoverage(float coverage, float alphaRef=0.5f, int alpha_channel=3, TimingContext *tc=0)
Attempts to scale the alpha channel so that a fraction coverage (between 0 and 1) of the surface has ...
nvtt::Surface::toCleanNormalMap
NVTT_API void toCleanNormalMap(TimingContext *tc=0)
Sets the z (blue) channel to x^2 + y^2.
nvtt::SurfaceSet
Surface-set struct for convenience of handling multi-level texture files such as DDS,...
Definition nvtt.h:1408
nvtt::TimingContext
A TimingContext is a way to collect timing data from a number of functions, and report how much time ...
Definition nvtt.h:1722
nvtt::TimingContext::PrintRecords
NVTT_API void PrintRecords()
Prints all records including their levels of nesting.
nvtt::TimingContext::GetRecordCount
NVTT_API int GetRecordCount()
Returns the number of timing records stored.
nvtt::TimingContext::GetRecord
NVTT_API size_t GetRecord(int i, char *outDescription, size_t outDescriptionSize, double &outSeconds)
Returns the description and length in seconds of the ith record.
nvtt::TimingContext::GetRecord
NVTT_DEPRECATED_API void GetRecord(int i, char *description, double &seconds)
Returns the description and length in seconds of the ith record.
nvtt::TimingContext::SetDetailLevel
NVTT_API void SetDetailLevel(int detailLevel)
Sets this TimingContext's detail level.
nvtt::TimingContext::TimingContext
NVTT_API TimingContext(int detailLevel=1)
Creates a TimingContext with the given detailLevel.
nvtt::TimingContext::~TimingContext
NVTT_API ~TimingContext()
Destructor.