Console-Swizzler
C library to swizzle DDS textures for console games
Loading...
Searching...
No Matches
SwizContext Struct Reference

Class for context of swizzling. More...

#include <console-swizzler.h>

Public Member Functions

_SWIZ_EXTERN SwizContextswizNewContext ()
 Creates a new context.
 
_SWIZ_EXTERN void swizFreeContext (SwizContext *context)
 Frees the memory of a context.
 
_SWIZ_EXTERN void swizContextInit (SwizContext *context)
 Initialize attributes of a context.
 
_SWIZ_EXTERN SwizError swizContextSetPlatform (SwizContext *context, SwizPlatform platform)
 Sets platform information to context.
 
_SWIZ_EXTERN SwizError swizContextSetTextureSize (SwizContext *context, int width, int height)
 Sets width and height to context.
 
_SWIZ_EXTERN void swizContextSetHasMips (SwizContext *context, int has_mips)
 Sets if textures have mipmaps or not.
 
_SWIZ_EXTERN SwizError swizContextSetArraySize (SwizContext *context, int array_size)
 Sets the number of textures in a buffer.
 
_SWIZ_EXTERN SwizError swizContextSetGobsHeight (SwizContext *context, int gobs_height)
 Sets the max height of GOBs blocks for switch.
 
_SWIZ_EXTERN SwizError swizContextSetBlockInfo (SwizContext *context, int block_width, int block_height, int block_data_size)
 Sets block size to context.
 
_SWIZ_EXTERN SwizError swizContextGetLastError (SwizContext *context)
 Gets error status of context.
 
_SWIZ_EXTERN uint32_t swizGetSwizzledSize (SwizContext *context)
 Gets binary size of swizzled data.
 
_SWIZ_EXTERN uint32_t swizGetUnswizzledSize (SwizContext *context)
 Gets binary size of unswizzled data.
 
_SWIZ_EXTERN uint8_t * swizAllocSwizzledData (SwizContext *context)
 Allocates a buffer for swizzled data.
 
_SWIZ_EXTERN uint8_t * swizAllocUnswizzledData (SwizContext *context)
 Allocates a buffer for unswizzled data.
 
_SWIZ_EXTERN SwizError swizDoSwizzle (const uint8_t *data, uint8_t *swizzled, SwizContext *context)
 Swizzles a texture.
 
_SWIZ_EXTERN SwizError swizDoUnswizzle (const uint8_t *data, uint8_t *unswizzled, SwizContext *context)
 Unswizzles a texture.
 

Detailed Description

Class for context of swizzling.

Member Function Documentation

◆ swizAllocSwizzledData()

_SWIZ_EXTERN uint8_t * swizAllocSwizzledData ( SwizContext context)

Allocates a buffer for swizzled data.

Note
Allocated data should be freed with free().
The size of allocated data should be equal to swizGetSwizzledSize()
Parameters
contextSwizContext instance
Returns
A pointer for allocated data. Null if it got errors

◆ swizAllocUnswizzledData()

_SWIZ_EXTERN uint8_t * swizAllocUnswizzledData ( SwizContext context)

Allocates a buffer for unswizzled data.

Note
Allocated data should be freed with free().
The size of allocated data should be equal to swizGetUnswizzledSize()
Parameters
contextSwizContext instance
Returns
A pointer for allocated data. Null if it got errors

◆ swizContextGetLastError()

_SWIZ_EXTERN SwizError swizContextGetLastError ( SwizContext context)

Gets error status of context.

Parameters
contextSwizContext instance
Returns
Non-zero if it got errors

◆ swizContextInit()

_SWIZ_EXTERN void swizContextInit ( SwizContext context)

Initialize attributes of a context.

Note
swizNewContext() calls this function internally.
Parameters
contextThe context to initialize

◆ swizContextSetArraySize()

_SWIZ_EXTERN SwizError swizContextSetArraySize ( SwizContext context,
int  array_size 
)

Sets the number of textures in a buffer.

Note
The default value is one.
Parameters
contextSwizContext instance
array_sizeThe number of textures in a buffer
Returns
Non-zero if it got errors

◆ swizContextSetBlockInfo()

_SWIZ_EXTERN SwizError swizContextSetBlockInfo ( SwizContext context,
int  block_width,
int  block_height,
int  block_data_size 
)

Sets block size to context.

Note
"Block" means a block of compression, not a block of swizzling.
4x4 for all BC formats. 1x1 for all uncompressed formats.
Parameters
contextSwizContext instance
block_widthWidth of a block
block_heightHeight of a block
block_data_sizeData size of a block
Returns
Non-zero if it got errors

◆ swizContextSetGobsHeight()

_SWIZ_EXTERN SwizError swizContextSetGobsHeight ( SwizContext context,
int  gobs_height 
)

Sets the max height of GOBs blocks for switch.

Note
The default value is 16. UE games use 8. Switch also supports 1, 2, 4, and 32.
Parameters
contextSwizContext instance
gobs_heightThe max height for blocks of GOBs
Returns
Non-zero if it got errors

◆ swizContextSetHasMips()

_SWIZ_EXTERN void swizContextSetHasMips ( SwizContext context,
int  has_mips 
)

Sets if textures have mipmaps or not.

Parameters
contextSwizContext instance
has_mipsWhether if texutures have mipmaps or not

◆ swizContextSetPlatform()

_SWIZ_EXTERN SwizError swizContextSetPlatform ( SwizContext context,
SwizPlatform  platform 
)

Sets platform information to context.

Parameters
contextSwizContext instance
platformThis should be #SWIZ_PLATFORM_PS4
Returns
Non-zero if it got errors

◆ swizContextSetTextureSize()

_SWIZ_EXTERN SwizError swizContextSetTextureSize ( SwizContext context,
int  width,
int  height 
)

Sets width and height to context.

Parameters
contextSwizContext instance
widthWidth of images
heightHeight of images
Returns
Non-zero if it got errors

◆ swizDoSwizzle()

_SWIZ_EXTERN SwizError swizDoSwizzle ( const uint8_t *  data,
uint8_t *  swizzled,
SwizContext context 
)

Swizzles a texture.

Parameters
dataUnswizzled data. Data size should be equal to swizGetUnswizzledSize().
swizzledSwizzled data. Data size should be equal to swizGetSwizzledSize().
contextSwizContext instance
Returns
Non-zero if it got errors

◆ swizDoUnswizzle()

_SWIZ_EXTERN SwizError swizDoUnswizzle ( const uint8_t *  data,
uint8_t *  unswizzled,
SwizContext context 
)

Unswizzles a texture.

Parameters
dataSwizzled data. Data size should be equal to swizGetSwizzledSize().
unswizzledUnswizzled data. Data size should be equal to swizGetUnswizzledSize().
contextSwizContext instance
Returns
Non-zero if it got errors

◆ swizFreeContext()

_SWIZ_EXTERN void swizFreeContext ( SwizContext context)

Frees the memory of a context.

Note
Every time a context is returned from swizNewContext(), this method should be called.
Parameters
contextThe context to free memory

◆ swizGetSwizzledSize()

_SWIZ_EXTERN uint32_t swizGetSwizzledSize ( SwizContext context)

Gets binary size of swizzled data.

Parameters
contextSwizContext instance
Returns
Binary size of swizzled data

◆ swizGetUnswizzledSize()

_SWIZ_EXTERN uint32_t swizGetUnswizzledSize ( SwizContext context)

Gets binary size of unswizzled data.

Parameters
contextSwizContext instance
Returns
Binary size of unswizzled data

◆ swizNewContext()

_SWIZ_EXTERN SwizContext * swizNewContext ( )

Creates a new context.


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