From 0f65d606023c7e1777bb1c17fc421f9c1c9cda47 Mon Sep 17 00:00:00 2001 From: Starnick Date: Thu, 18 Oct 2018 20:29:57 -0400 Subject: [PATCH 1/2] Updated C-API to support 2D array textures + added missing enum values from nvtt.h --- .../vc12/Nvidia.TextureTools/TextureTools.cs | 38 +++++++++++++++---- src/nvtt/nvtt_wrapper.cpp | 4 +- src/nvtt/nvtt_wrapper.h | 38 +++++++++++++++++-- 3 files changed, 66 insertions(+), 14 deletions(-) diff --git a/project/vc12/Nvidia.TextureTools/TextureTools.cs b/project/vc12/Nvidia.TextureTools/TextureTools.cs index 3894da3..3ce8ecd 100644 --- a/project/vc12/Nvidia.TextureTools/TextureTools.cs +++ b/project/vc12/Nvidia.TextureTools/TextureTools.cs @@ -36,9 +36,23 @@ namespace Nvidia.TextureTools CTX1, // Not supported on CPU yet. BC6, - BC7, // Not supported yet. + BC7, - DXT1_Luma, + BC3_RGBM, + + ETC1, + ETC2_R, + ETC2_RG, + ETC2_RGB, + ETC2_RGBA, + ETC2_RGB_A1, + + ETC2_RGBM, + + PVR_2BPP_RGB, // Using PVR textools. + PVR_4BPP_RGB, + PVR_2BPP_RGBA, + PVR_4BPP_RGBA } #endregion @@ -75,6 +89,8 @@ namespace Nvidia.TextureTools { Texture2D, TextureCube, + Texture3D, + Texture2DArray } #endregion @@ -84,8 +100,11 @@ namespace Nvidia.TextureTools /// public enum InputFormat { - BGRA_8UB - } + BGRA_8UB, // Normalized [0, 1] 8 bit fixed point. + RGBA_16F, // 16 bit floating point. + RGBA_32F, // 32 bit floating point. + R_32F, // Single channel 32 bit floating point. + } #endregion #region public enum MipmapFilter @@ -120,7 +139,10 @@ namespace Nvidia.TextureTools None, ToNextPowerOfTwo, ToNearestPowerOfTwo, - ToPreviousPowerOfTwo + ToPreviousPowerOfTwo, + ToNextMultipleOfFour, + ToNearestMultipleOfFour, + ToPreviousMultipleOfFour } #endregion @@ -168,7 +190,7 @@ namespace Nvidia.TextureTools private extern static void nvttDestroyInputOptions(IntPtr inputOptions); [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsTextureLayout(IntPtr inputOptions, TextureType type, int w, int h, int d); + private extern static void nvttSetInputOptionsTextureLayout(IntPtr inputOptions, TextureType type, int w, int h, int d, int arraySize); [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] private extern static void nvttResetInputOptionsTextureLayout(IntPtr inputOptions); @@ -236,9 +258,9 @@ namespace Nvidia.TextureTools nvttDestroyInputOptions(options); } - public void SetTextureLayout(TextureType type, int w, int h, int d) + public void SetTextureLayout(TextureType type, int w, int h, int d, int arraySize = 1) { - nvttSetInputOptionsTextureLayout(options, type, w, h, d); + nvttSetInputOptionsTextureLayout(options, type, w, h, d, arraySize); } public void ResetTextureLayout() { diff --git a/src/nvtt/nvtt_wrapper.cpp b/src/nvtt/nvtt_wrapper.cpp index 5a21242..012aaa4 100644 --- a/src/nvtt/nvtt_wrapper.cpp +++ b/src/nvtt/nvtt_wrapper.cpp @@ -78,9 +78,9 @@ void nvttDestroyInputOptions(NvttInputOptions * inputOptions) delete inputOptions; } -void nvttSetInputOptionsTextureLayout(NvttInputOptions * inputOptions, NvttTextureType type, int w, int h, int d) +void nvttSetInputOptionsTextureLayout(NvttInputOptions * inputOptions, NvttTextureType type, int w, int h, int d, int arraySize) { - inputOptions->setTextureLayout((nvtt::TextureType)type, w, h, d); + inputOptions->setTextureLayout((nvtt::TextureType)type, w, h, d, arraySize); } void nvttResetInputOptionsTextureLayout(NvttInputOptions * inputOptions) diff --git a/src/nvtt/nvtt_wrapper.h b/src/nvtt/nvtt_wrapper.h index 76fdac6..aeec2e5 100644 --- a/src/nvtt/nvtt_wrapper.h +++ b/src/nvtt/nvtt_wrapper.h @@ -71,10 +71,10 @@ typedef enum // DX9 formats. NVTT_Format_DXT1, - NVTT_Format_DXT1a, + NVTT_Format_DXT1a, // DXT1 with binary alpha. NVTT_Format_DXT3, NVTT_Format_DXT5, - NVTT_Format_DXT5n, + NVTT_Format_DXT5n, // Compressed HILO: R=1, G=y, B=0, A=x // DX10 formats. NVTT_Format_BC1 = NVTT_Format_DXT1, @@ -84,6 +84,28 @@ typedef enum NVTT_Format_BC3n = NVTT_Format_DXT5n, NVTT_Format_BC4, NVTT_Format_BC5, + + NVTT_Format_DXT1n, // Not supported. + NVTT_Format_CTX1, // Not supported. + + NVTT_Format_BC6, + NVTT_Format_BC7, + + NVTT_Format_BC3_RGBM, + + NVTT_Format_ETC1, + NVTT_Format_ETC2_R, + NVTT_Format_ETC2_RG, + NVTT_Format_ETC2_RGB, + NVTT_Format_ETC2_RGBA, + NVTT_Format_ETC2_RGB_A1, + + NVTT_Format_ETC2_RGBM, + + NVTT_Format_PVR_2BPP_RGB, // Using PVR textools. + NVTT_Format_PVR_4BPP_RGB, + NVTT_Format_PVR_2BPP_RGBA, + NVTT_Format_PVR_4BPP_RGBA, } NvttFormat; /// Quality modes. @@ -108,12 +130,17 @@ typedef enum { NVTT_TextureType_2D, NVTT_TextureType_Cube, + TextureType_3D, + TextureType_Array, } NvttTextureType; /// Input formats. typedef enum { - NVTT_InputFormat_BGRA_8UB, + NVTT_InputFormat_BGRA_8UB, // Normalized [0, 1] 8 bit fixed point. + NVTT_InputFormat_RGBA_16F, // 16 bit floating point. + NVTT_InputFormat_RGBA_32F, // 32 bit floating point. + NVTT_InputFormat_R_32F, // Single channel 32 bit floating point. } NvttInputFormat; /// Mipmap downsampling filters. @@ -131,6 +158,9 @@ typedef enum NVTT_RoundMode_ToNextPowerOfTwo, NVTT_RoundMode_ToNearestPowerOfTwo, NVTT_RoundMode_ToPreviousPowerOfTwo, + NVTT_RoundMode_ToNextMultipleOfFour, // (New in NVTT 2.1) + NVTT_RoundMode_ToNearestMultipleOfFour, // (New in NVTT 2.1) + NVTT_RoundMode_ToPreviousMultipleOfFour, // (New in NVTT 2.1) } NvttRoundMode; /// Alpha mode. @@ -175,7 +205,7 @@ typedef void (* nvttEndImageHandler)(); NVTT_API NvttInputOptions * nvttCreateInputOptions(); NVTT_API void nvttDestroyInputOptions(NvttInputOptions * inputOptions); -NVTT_API void nvttSetInputOptionsTextureLayout(NvttInputOptions * inputOptions, NvttTextureType type, int w, int h, int d); +NVTT_API void nvttSetInputOptionsTextureLayout(NvttInputOptions * inputOptions, NvttTextureType type, int w, int h, int d, int arraySize); NVTT_API void nvttResetInputOptionsTextureLayout(NvttInputOptions * inputOptions); NVTT_API NvttBoolean nvttSetInputOptionsMipmapData(NvttInputOptions * inputOptions, const void * data, int w, int h, int d, int face, int mipmap); NVTT_API void nvttSetInputOptionsFormat(NvttInputOptions * inputOptions, NvttInputFormat format); From 40f395ef1937c4b54f0695d4d6bb7a7359850cb5 Mon Sep 17 00:00:00 2001 From: Starnick Date: Thu, 18 Oct 2018 20:34:07 -0400 Subject: [PATCH 2/2] spaces->tabs consistency --- .../vc12/Nvidia.TextureTools/TextureTools.cs | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/project/vc12/Nvidia.TextureTools/TextureTools.cs b/project/vc12/Nvidia.TextureTools/TextureTools.cs index 3ce8ecd..ca1bf0c 100644 --- a/project/vc12/Nvidia.TextureTools/TextureTools.cs +++ b/project/vc12/Nvidia.TextureTools/TextureTools.cs @@ -38,21 +38,21 @@ namespace Nvidia.TextureTools BC6, BC7, - BC3_RGBM, + BC3_RGBM, - ETC1, - ETC2_R, - ETC2_RG, - ETC2_RGB, - ETC2_RGBA, - ETC2_RGB_A1, + ETC1, + ETC2_R, + ETC2_RG, + ETC2_RGB, + ETC2_RGBA, + ETC2_RGB_A1, - ETC2_RGBM, + ETC2_RGBM, - PVR_2BPP_RGB, // Using PVR textools. - PVR_4BPP_RGB, - PVR_2BPP_RGBA, - PVR_4BPP_RGBA + PVR_2BPP_RGB, // Using PVR textools. + PVR_4BPP_RGB, + PVR_2BPP_RGBA, + PVR_4BPP_RGBA } #endregion @@ -101,10 +101,10 @@ namespace Nvidia.TextureTools public enum InputFormat { BGRA_8UB, // Normalized [0, 1] 8 bit fixed point. - RGBA_16F, // 16 bit floating point. - RGBA_32F, // 32 bit floating point. - R_32F, // Single channel 32 bit floating point. - } + RGBA_16F, // 16 bit floating point. + RGBA_32F, // 32 bit floating point. + R_32F, // Single channel 32 bit floating point. + } #endregion #region public enum MipmapFilter @@ -140,9 +140,9 @@ namespace Nvidia.TextureTools ToNextPowerOfTwo, ToNearestPowerOfTwo, ToPreviousPowerOfTwo, - ToNextMultipleOfFour, - ToNearestMultipleOfFour, - ToPreviousMultipleOfFour + ToNextMultipleOfFour, + ToNearestMultipleOfFour, + ToPreviousMultipleOfFour } #endregion