Class ktxBasisParams

java.lang.Object
org.lwjgl.system.Pointer.Default
org.lwjgl.system.Struct<ktxBasisParams>
org.lwjgl.util.ktx.ktxBasisParams
All Implemented Interfaces:
AutoCloseable, org.lwjgl.system.NativeResource, org.lwjgl.system.Pointer

public class ktxBasisParams extends org.lwjgl.system.Struct<ktxBasisParams> implements org.lwjgl.system.NativeResource
Structure for passing extended parameters to Texture2_CompressBasisEx.

If you only want default values, use Texture2_CompressBasis. Here, at a minimum you must initialize the structure as follows:


   ktxBasisParams params = {0};
   params.structSize = sizeof(params);
   params.compressionLevel = KTX_ETC1S_DEFAULT_COMPRESSION_LEVEL;

compressionLevel has to be explicitly set because 0 is a valid compressionLevel but is not the default used by the BasisU encoder when no value is set. Only the other settings that are to be non-default must be non-zero.

Layout


 struct ktxBasisParams {
     ktx_uint32_t structSize();
     ktx_bool_t uastc();
     ktx_bool_t verbose();
     ktx_bool_t noSSE();
     ktx_uint32_t threadCount();
     ktx_uint32_t compressionLevel();
     ktx_uint32_t qualityLevel();
     ktx_uint32_t maxEndpoints();
     float endpointRDOThreshold();
     ktx_uint32_t maxSelectors();
     float selectorRDOThreshold();
     char inputSwizzle()[4];
     ktx_bool_t normalMap();
     ktx_bool_t separateRGToRGB_A();
     ktx_bool_t preSwizzle();
     ktx_bool_t noEndpointRDO();
     ktx_bool_t noSelectorRDO();
     ktx_pack_uastc_flags uastcFlags();
     ktx_bool_t uastcRDO();
     float uastcRDOQualityScalar();
     ktx_uint32_t uastcRDODictSize();
     float uastcRDOMaxSmoothBlockErrorScale();
     float uastcRDOMaxSmoothBlockStdDev();
     ktx_bool_t uastcRDODontFavorSimplerModes();
     ktx_bool_t uastcRDONoMultithreading();
 }
  • Field Details

    • SIZEOF

      public static final int SIZEOF
      The struct size in bytes.
    • ALIGNOF

      public static final int ALIGNOF
      The struct alignment in bytes.
    • STRUCTSIZE

      public static final int STRUCTSIZE
      The struct member offsets.
    • UASTC

      public static final int UASTC
      The struct member offsets.
    • VERBOSE

      public static final int VERBOSE
      The struct member offsets.
    • NOSSE

      public static final int NOSSE
      The struct member offsets.
    • THREADCOUNT

      public static final int THREADCOUNT
      The struct member offsets.
    • COMPRESSIONLEVEL

      public static final int COMPRESSIONLEVEL
      The struct member offsets.
    • QUALITYLEVEL

      public static final int QUALITYLEVEL
      The struct member offsets.
    • MAXENDPOINTS

      public static final int MAXENDPOINTS
      The struct member offsets.
    • ENDPOINTRDOTHRESHOLD

      public static final int ENDPOINTRDOTHRESHOLD
      The struct member offsets.
    • MAXSELECTORS

      public static final int MAXSELECTORS
      The struct member offsets.
    • SELECTORRDOTHRESHOLD

      public static final int SELECTORRDOTHRESHOLD
      The struct member offsets.
    • INPUTSWIZZLE

      public static final int INPUTSWIZZLE
      The struct member offsets.
    • NORMALMAP

      public static final int NORMALMAP
      The struct member offsets.
    • SEPARATERGTORGB_A

      public static final int SEPARATERGTORGB_A
      The struct member offsets.
    • PRESWIZZLE

      public static final int PRESWIZZLE
      The struct member offsets.
    • NOENDPOINTRDO

      public static final int NOENDPOINTRDO
      The struct member offsets.
    • NOSELECTORRDO

      public static final int NOSELECTORRDO
      The struct member offsets.
    • UASTCFLAGS

      public static final int UASTCFLAGS
      The struct member offsets.
    • UASTCRDO

      public static final int UASTCRDO
      The struct member offsets.
    • UASTCRDOQUALITYSCALAR

      public static final int UASTCRDOQUALITYSCALAR
      The struct member offsets.
    • UASTCRDODICTSIZE

      public static final int UASTCRDODICTSIZE
      The struct member offsets.
    • UASTCRDOMAXSMOOTHBLOCKERRORSCALE

      public static final int UASTCRDOMAXSMOOTHBLOCKERRORSCALE
      The struct member offsets.
    • UASTCRDOMAXSMOOTHBLOCKSTDDEV

      public static final int UASTCRDOMAXSMOOTHBLOCKSTDDEV
      The struct member offsets.
    • UASTCRDODONTFAVORSIMPLERMODES

      public static final int UASTCRDODONTFAVORSIMPLERMODES
      The struct member offsets.
    • UASTCRDONOMULTITHREADING

      public static final int UASTCRDONOMULTITHREADING
      The struct member offsets.
  • Constructor Details

    • ktxBasisParams

      public ktxBasisParams(ByteBuffer container)
      Creates a ktxBasisParams instance at the current position of the specified ByteBuffer container. Changes to the buffer's content will be visible to the struct instance and vice versa.

      The created instance holds a strong reference to the container object.

  • Method Details

    • sizeof

      public int sizeof()
      Specified by:
      sizeof in class org.lwjgl.system.Struct<ktxBasisParams>
    • structSize

      public int structSize()
      Size of this struct.

      Used so library can tell which version of struct is being passed.

    • uastc

      public boolean uastc()
      True to use UASTC base, false to use ETC1S base.
    • verbose

      public boolean verbose()
      If true, prints Basis Universal encoder operation details to stdout.

      Not recommended for GUI apps.

    • noSSE

      public boolean noSSE()
      True to forbid use of the SSE instruction set.

      Ignored if CPU does not support SSE.

    • threadCount

      public int threadCount()
      Number of threads used for compression. Default is 1.
    • compressionLevel

      public int compressionLevel()
      Encoding speed vs. quality tradeoff.

      Range is [0,5]. Higher values are slower, but give higher quality. There is no default. Callers must explicitly set this value. Callers can use ETC1S_DEFAULT_COMPRESSION_LEVEL as a default value. Currently this is 2.

    • qualityLevel

      public int qualityLevel()
      Compression quality.

      Range is [1,255]. Lower gives better compression/lower quality/faster. Higher gives less compression/higher quality/slower. This automatically determines values for maxEndpoints, maxSelectors, endpointRDOThreshold and selectorRDOThreshold for the target quality level. Setting these parameters overrides the values determined by qualityLevel which defaults to 128 if neither it nor both of maxEndpoints and maxSelectors have been set.

      Note: Both of maxEndpoints and maxSelectors must be set for them to have any effect. qualityLevel will only determine values for endpointRDOThreshold and selectorRDOThreshold when its value exceeds 128, otherwise their defaults will be used.

    • maxEndpoints

      public int maxEndpoints()
      Manually set the max number of color endpoint clusters.

      Range is [1,16128]. Default is 0, unset. If this is set, maxSelectors must also be set, otherwise the value will be ignored.

    • endpointRDOThreshold

      public float endpointRDOThreshold()
      Set endpoint RDO quality threshold.

      The default is 1.25. Lower is higher quality but less quality per output bit (try [1.0,3.0]). This will override the value chosen by qualityLevel.

    • maxSelectors

      public int maxSelectors()
      Manually set the max number of color selector clusters.

      Range is [1,16128]. Default is 0, unset. If this is set, maxEndpoints must also be set, otherwise the value will be ignored.

    • selectorRDOThreshold

      public float selectorRDOThreshold()
      Set selector RDO quality threshold.

      The default is 1.5. Lower is higher quality but less quality per output bit (try [1.0,3.0]). This will override the value chosen by qualityLevel.

    • inputSwizzle

      public ByteBuffer inputSwizzle()
      A swizzle to apply before encoding.

      It must match the regular expression /^[rgba01]{4}$/. If both this and preSwizzle are specified Texture2_CompressBasisEx will raise INVALID_OPERATION.

    • inputSwizzle

      public byte inputSwizzle(int index)
      A swizzle to apply before encoding.

      It must match the regular expression /^[rgba01]{4}$/. If both this and preSwizzle are specified Texture2_CompressBasisEx will raise INVALID_OPERATION.

    • normalMap

      public boolean normalMap()
      Tunes codec parameters for better quality on normal maps (no selector RDO, no endpoint RDO) and sets the texture's DFD appropriately.

      Only valid for linear textures.

    • separateRGToRGB_A

      public boolean separateRGToRGB_A()
      deprecated
    • preSwizzle

      public boolean preSwizzle()
      If the texture has KTXswizzle metadata, apply it before compressing.

      Swizzling, like rabb may yield drastically different error metrics if done after supercompression.

    • noEndpointRDO

      public boolean noEndpointRDO()
      Disable endpoint rate distortion optimizations.

      Slightly faster, less noisy output, but lower quality per output bit. Default is FALSE.

    • noSelectorRDO

      public boolean noSelectorRDO()
      Disable selector rate distortion optimizations.

      Slightly faster, less noisy output, but lower quality per output bit. Default is FALSE.

    • uastcFlags

      public int uastcFlags()
      A set of ktx_pack_uastc_flag_bits_e controlling UASTC encoding.
    • uastcRDO

      public boolean uastcRDO()
      Enable Rate Distortion Optimization (RDO) post-processing.
    • uastcRDOQualityScalar

      public float uastcRDOQualityScalar()
      UASTC RDO quality scalar (lambda).

      Lower values yield higher quality/larger LZ compressed files, higher values yield lower quality/smaller LZ compressed files. A good range to try is [.2,4]. Full range is [.001,50.0]. Default is 1.0.

    • uastcRDODictSize

      public int uastcRDODictSize()
      UASTC RDO dictionary size in bytes.

      Default is 4096. Lower values=faster, but give less compression. Range is [64,65536].

    • uastcRDOMaxSmoothBlockErrorScale

      public float uastcRDOMaxSmoothBlockErrorScale()
      UASTC RDO max smooth block error scale.

      Range is [1,300]. Default is 10.0, 1.0 is disabled. Larger values suppress more artifacts (and allocate more bits) on smooth blocks.

    • uastcRDOMaxSmoothBlockStdDev

      public float uastcRDOMaxSmoothBlockStdDev()
      UASTC RDO max smooth block standard deviation.

      Range is [.01,65536.0]. Default is 18.0. Larger values expand the range of blocks considered smooth.

    • uastcRDODontFavorSimplerModes

      public boolean uastcRDODontFavorSimplerModes()
      Do not favor simpler UASTC modes in RDO mode.
    • uastcRDONoMultithreading

      public boolean uastcRDONoMultithreading()
      Disable RDO multithreading (slightly higher compression, deterministic).
    • structSize

      public ktxBasisParams structSize(int value)
      Sets the specified value to the structSize() field.
    • uastc

      public ktxBasisParams uastc(boolean value)
      Sets the specified value to the uastc() field.
    • verbose

      public ktxBasisParams verbose(boolean value)
      Sets the specified value to the verbose() field.
    • noSSE

      public ktxBasisParams noSSE(boolean value)
      Sets the specified value to the noSSE() field.
    • threadCount

      public ktxBasisParams threadCount(int value)
      Sets the specified value to the threadCount() field.
    • compressionLevel

      public ktxBasisParams compressionLevel(int value)
      Sets the specified value to the compressionLevel() field.
    • qualityLevel

      public ktxBasisParams qualityLevel(int value)
      Sets the specified value to the qualityLevel() field.
    • maxEndpoints

      public ktxBasisParams maxEndpoints(int value)
      Sets the specified value to the maxEndpoints() field.
    • endpointRDOThreshold

      public ktxBasisParams endpointRDOThreshold(float value)
      Sets the specified value to the endpointRDOThreshold() field.
    • maxSelectors

      public ktxBasisParams maxSelectors(int value)
      Sets the specified value to the maxSelectors() field.
    • selectorRDOThreshold

      public ktxBasisParams selectorRDOThreshold(float value)
      Sets the specified value to the selectorRDOThreshold() field.
    • inputSwizzle

      public ktxBasisParams inputSwizzle(ByteBuffer value)
      Copies the specified ByteBuffer to the inputSwizzle() field.
    • inputSwizzle

      public ktxBasisParams inputSwizzle(int index, byte value)
      Sets the specified value at the specified index of the inputSwizzle() field.
    • normalMap

      public ktxBasisParams normalMap(boolean value)
      Sets the specified value to the normalMap() field.
    • separateRGToRGB_A

      public ktxBasisParams separateRGToRGB_A(boolean value)
      Sets the specified value to the separateRGToRGB_A() field.
    • preSwizzle

      public ktxBasisParams preSwizzle(boolean value)
      Sets the specified value to the preSwizzle() field.
    • noEndpointRDO

      public ktxBasisParams noEndpointRDO(boolean value)
      Sets the specified value to the noEndpointRDO() field.
    • noSelectorRDO

      public ktxBasisParams noSelectorRDO(boolean value)
      Sets the specified value to the noSelectorRDO() field.
    • uastcFlags

      public ktxBasisParams uastcFlags(int value)
      Sets the specified value to the uastcFlags() field.
    • uastcRDO

      public ktxBasisParams uastcRDO(boolean value)
      Sets the specified value to the uastcRDO() field.
    • uastcRDOQualityScalar

      public ktxBasisParams uastcRDOQualityScalar(float value)
      Sets the specified value to the uastcRDOQualityScalar() field.
    • uastcRDODictSize

      public ktxBasisParams uastcRDODictSize(int value)
      Sets the specified value to the uastcRDODictSize() field.
    • uastcRDOMaxSmoothBlockErrorScale

      public ktxBasisParams uastcRDOMaxSmoothBlockErrorScale(float value)
      Sets the specified value to the uastcRDOMaxSmoothBlockErrorScale() field.
    • uastcRDOMaxSmoothBlockStdDev

      public ktxBasisParams uastcRDOMaxSmoothBlockStdDev(float value)
      Sets the specified value to the uastcRDOMaxSmoothBlockStdDev() field.
    • uastcRDODontFavorSimplerModes

      public ktxBasisParams uastcRDODontFavorSimplerModes(boolean value)
      Sets the specified value to the uastcRDODontFavorSimplerModes() field.
    • uastcRDONoMultithreading

      public ktxBasisParams uastcRDONoMultithreading(boolean value)
      Sets the specified value to the uastcRDONoMultithreading() field.
    • set

      public ktxBasisParams set(int structSize, boolean uastc, boolean verbose, boolean noSSE, int threadCount, int compressionLevel, int qualityLevel, int maxEndpoints, float endpointRDOThreshold, int maxSelectors, float selectorRDOThreshold, ByteBuffer inputSwizzle, boolean normalMap, boolean separateRGToRGB_A, boolean preSwizzle, boolean noEndpointRDO, boolean noSelectorRDO, int uastcFlags, boolean uastcRDO, float uastcRDOQualityScalar, int uastcRDODictSize, float uastcRDOMaxSmoothBlockErrorScale, float uastcRDOMaxSmoothBlockStdDev, boolean uastcRDODontFavorSimplerModes, boolean uastcRDONoMultithreading)
      Initializes this struct with the specified values.
    • set

      public ktxBasisParams set(ktxBasisParams src)
      Copies the specified struct data to this struct.
      Parameters:
      src - the source struct
      Returns:
      this struct
    • malloc

      public static ktxBasisParams malloc()
      Returns a new ktxBasisParams instance allocated with memAlloc. The instance must be explicitly freed.
    • calloc

      public static ktxBasisParams calloc()
      Returns a new ktxBasisParams instance allocated with memCalloc. The instance must be explicitly freed.
    • create

      public static ktxBasisParams create()
      Returns a new ktxBasisParams instance allocated with BufferUtils.
    • create

      public static ktxBasisParams create(long address)
      Returns a new ktxBasisParams instance for the specified memory address.
    • createSafe

      public static @Nullable ktxBasisParams createSafe(long address)
      Like create, but returns null if address is NULL.
    • malloc

      public static ktxBasisParams.Buffer malloc(int capacity)
      Returns a new ktxBasisParams.Buffer instance allocated with memAlloc. The instance must be explicitly freed.
      Parameters:
      capacity - the buffer capacity
    • calloc

      public static ktxBasisParams.Buffer calloc(int capacity)
      Returns a new ktxBasisParams.Buffer instance allocated with memCalloc. The instance must be explicitly freed.
      Parameters:
      capacity - the buffer capacity
    • create

      public static ktxBasisParams.Buffer create(int capacity)
      Returns a new ktxBasisParams.Buffer instance allocated with BufferUtils.
      Parameters:
      capacity - the buffer capacity
    • create

      public static ktxBasisParams.Buffer create(long address, int capacity)
      Create a ktxBasisParams.Buffer instance at the specified memory.
      Parameters:
      address - the memory address
      capacity - the buffer capacity
    • createSafe

      public static @Nullable ktxBasisParams.Buffer createSafe(long address, int capacity)
      Like create, but returns null if address is NULL.
    • malloc

      public static ktxBasisParams malloc(org.lwjgl.system.MemoryStack stack)
      Returns a new ktxBasisParams instance allocated on the specified MemoryStack.
      Parameters:
      stack - the stack from which to allocate
    • calloc

      public static ktxBasisParams calloc(org.lwjgl.system.MemoryStack stack)
      Returns a new ktxBasisParams instance allocated on the specified MemoryStack and initializes all its bits to zero.
      Parameters:
      stack - the stack from which to allocate
    • malloc

      public static ktxBasisParams.Buffer malloc(int capacity, org.lwjgl.system.MemoryStack stack)
      Returns a new ktxBasisParams.Buffer instance allocated on the specified MemoryStack.
      Parameters:
      capacity - the buffer capacity
      stack - the stack from which to allocate
    • calloc

      public static ktxBasisParams.Buffer calloc(int capacity, org.lwjgl.system.MemoryStack stack)
      Returns a new ktxBasisParams.Buffer instance allocated on the specified MemoryStack and initializes all its bits to zero.
      Parameters:
      capacity - the buffer capacity
      stack - the stack from which to allocate
    • nstructSize

      public static int nstructSize(long struct)
      Unsafe version of structSize().
    • nuastc

      public static boolean nuastc(long struct)
      Unsafe version of uastc().
    • nverbose

      public static boolean nverbose(long struct)
      Unsafe version of verbose().
    • nnoSSE

      public static boolean nnoSSE(long struct)
      Unsafe version of noSSE().
    • nthreadCount

      public static int nthreadCount(long struct)
      Unsafe version of threadCount().
    • ncompressionLevel

      public static int ncompressionLevel(long struct)
      Unsafe version of compressionLevel().
    • nqualityLevel

      public static int nqualityLevel(long struct)
      Unsafe version of qualityLevel().
    • nmaxEndpoints

      public static int nmaxEndpoints(long struct)
      Unsafe version of maxEndpoints().
    • nendpointRDOThreshold

      public static float nendpointRDOThreshold(long struct)
      Unsafe version of endpointRDOThreshold().
    • nmaxSelectors

      public static int nmaxSelectors(long struct)
      Unsafe version of maxSelectors().
    • nselectorRDOThreshold

      public static float nselectorRDOThreshold(long struct)
      Unsafe version of selectorRDOThreshold().
    • ninputSwizzle

      public static ByteBuffer ninputSwizzle(long struct)
      Unsafe version of inputSwizzle().
    • ninputSwizzle

      public static byte ninputSwizzle(long struct, int index)
      Unsafe version of inputSwizzle.
    • nnormalMap

      public static boolean nnormalMap(long struct)
      Unsafe version of normalMap().
    • nseparateRGToRGB_A

      public static boolean nseparateRGToRGB_A(long struct)
      Unsafe version of separateRGToRGB_A().
    • npreSwizzle

      public static boolean npreSwizzle(long struct)
      Unsafe version of preSwizzle().
    • nnoEndpointRDO

      public static boolean nnoEndpointRDO(long struct)
      Unsafe version of noEndpointRDO().
    • nnoSelectorRDO

      public static boolean nnoSelectorRDO(long struct)
      Unsafe version of noSelectorRDO().
    • nuastcFlags

      public static int nuastcFlags(long struct)
      Unsafe version of uastcFlags().
    • nuastcRDO

      public static boolean nuastcRDO(long struct)
      Unsafe version of uastcRDO().
    • nuastcRDOQualityScalar

      public static float nuastcRDOQualityScalar(long struct)
      Unsafe version of uastcRDOQualityScalar().
    • nuastcRDODictSize

      public static int nuastcRDODictSize(long struct)
      Unsafe version of uastcRDODictSize().
    • nuastcRDOMaxSmoothBlockErrorScale

      public static float nuastcRDOMaxSmoothBlockErrorScale(long struct)
    • nuastcRDOMaxSmoothBlockStdDev

      public static float nuastcRDOMaxSmoothBlockStdDev(long struct)
    • nuastcRDODontFavorSimplerModes

      public static boolean nuastcRDODontFavorSimplerModes(long struct)
    • nuastcRDONoMultithreading

      public static boolean nuastcRDONoMultithreading(long struct)
      Unsafe version of uastcRDONoMultithreading().
    • nstructSize

      public static void nstructSize(long struct, int value)
      Unsafe version of structSize.
    • nuastc

      public static void nuastc(long struct, boolean value)
      Unsafe version of uastc.
    • nverbose

      public static void nverbose(long struct, boolean value)
      Unsafe version of verbose.
    • nnoSSE

      public static void nnoSSE(long struct, boolean value)
      Unsafe version of noSSE.
    • nthreadCount

      public static void nthreadCount(long struct, int value)
      Unsafe version of threadCount.
    • ncompressionLevel

      public static void ncompressionLevel(long struct, int value)
      Unsafe version of compressionLevel.
    • nqualityLevel

      public static void nqualityLevel(long struct, int value)
      Unsafe version of qualityLevel.
    • nmaxEndpoints

      public static void nmaxEndpoints(long struct, int value)
      Unsafe version of maxEndpoints.
    • nendpointRDOThreshold

      public static void nendpointRDOThreshold(long struct, float value)
      Unsafe version of endpointRDOThreshold.
    • nmaxSelectors

      public static void nmaxSelectors(long struct, int value)
      Unsafe version of maxSelectors.
    • nselectorRDOThreshold

      public static void nselectorRDOThreshold(long struct, float value)
      Unsafe version of selectorRDOThreshold.
    • ninputSwizzle

      public static void ninputSwizzle(long struct, ByteBuffer value)
      Unsafe version of inputSwizzle.
    • ninputSwizzle

      public static void ninputSwizzle(long struct, int index, byte value)
      Unsafe version of inputSwizzle.
    • nnormalMap

      public static void nnormalMap(long struct, boolean value)
      Unsafe version of normalMap.
    • nseparateRGToRGB_A

      public static void nseparateRGToRGB_A(long struct, boolean value)
      Unsafe version of separateRGToRGB_A.
    • npreSwizzle

      public static void npreSwizzle(long struct, boolean value)
      Unsafe version of preSwizzle.
    • nnoEndpointRDO

      public static void nnoEndpointRDO(long struct, boolean value)
      Unsafe version of noEndpointRDO.
    • nnoSelectorRDO

      public static void nnoSelectorRDO(long struct, boolean value)
      Unsafe version of noSelectorRDO.
    • nuastcFlags

      public static void nuastcFlags(long struct, int value)
      Unsafe version of uastcFlags.
    • nuastcRDO

      public static void nuastcRDO(long struct, boolean value)
      Unsafe version of uastcRDO.
    • nuastcRDOQualityScalar

      public static void nuastcRDOQualityScalar(long struct, float value)
      Unsafe version of uastcRDOQualityScalar.
    • nuastcRDODictSize

      public static void nuastcRDODictSize(long struct, int value)
      Unsafe version of uastcRDODictSize.
    • nuastcRDOMaxSmoothBlockErrorScale

      public static void nuastcRDOMaxSmoothBlockErrorScale(long struct, float value)
    • nuastcRDOMaxSmoothBlockStdDev

      public static void nuastcRDOMaxSmoothBlockStdDev(long struct, float value)
      Unsafe version of uastcRDOMaxSmoothBlockStdDev.
    • nuastcRDODontFavorSimplerModes

      public static void nuastcRDODontFavorSimplerModes(long struct, boolean value)
    • nuastcRDONoMultithreading

      public static void nuastcRDONoMultithreading(long struct, boolean value)
      Unsafe version of uastcRDONoMultithreading.