dfdutils
Loading...
Searching...
No Matches
createdfd.c File Reference

Utilities for creating data format descriptors. More...

#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <KHR/khr_df.h>
#include "dfd.h"

Functions

uint32_t * createDFDUnpacked (int bigEndian, int numChannels, int bytes, int redBlueSwap, enum VkSuffix suffix)
 Create a Data Format Descriptor for an unpacked format.
uint32_t * createDFDPackedShifted (int bigEndian, int numChannels, int bits[], int shiftBits[], int channels[], enum VkSuffix suffix)
 Create a Data Format Descriptor for a packed format.
uint32_t * createDFDPacked (int bigEndian, int numChannels, int bits[], int channels[], enum VkSuffix suffix)
 Create a Data Format Descriptor for a packed format.
uint32_t * createDFDCompressed (enum VkCompScheme compScheme, int bwidth, int bheight, int bdepth, enum VkSuffix suffix)
 Create a Data Format Descriptor for a compressed format.
uint32_t * createDFDDepthStencil (int depthBits, int stencilBits, int sizeBytes)
 Create a Data Format Descriptor for a depth-stencil format.
uint32_t * createDFDAlpha (int bigEndian, int bytes, enum VkSuffix suffix)
 Create a Data Format Descriptor for an alpha-only format.

Detailed Description

Utilities for creating data format descriptors.

Function Documentation

◆ createDFDAlpha()

uint32_t * createDFDAlpha ( int bigEndian,
int bytes,
enum VkSuffix suffix )

Create a Data Format Descriptor for an alpha-only format.

Parameters
bigEndianSet to 1 for big-endian byte ordering and 0 for little-endian byte ordering.
bytesThe number of bytes per channel.
suffixIndicates the format suffix for the type.
Returns
A data format descriptor in malloc'd data. The caller is responsible for freeing the descriptor.

◆ createDFDCompressed()

uint32_t * createDFDCompressed ( enum VkCompScheme compScheme,
int bwidth,
int bheight,
int bdepth,
enum VkSuffix suffix )

Create a Data Format Descriptor for a compressed format.

Parameters
compSchemeVulkan-style compression scheme enumeration.
bwidthBlock width in texel coordinates.
bheightBlock height in texel coordinates.
bdepthBlock depth in texel coordinates.
Author
Mark Callow, github.com/MarkCallow.
Parameters
suffixIndicates the format suffix for the type.
Returns
A data format descriptor in malloc'd data. The caller is responsible for freeing the descriptor.

◆ createDFDDepthStencil()

uint32_t * createDFDDepthStencil ( int depthBits,
int stencilBits,
int sizeBytes )

Create a Data Format Descriptor for a depth-stencil format.

Parameters
depthBitsThe numeber of bits in the depth channel.
stencilBitsThe numeber of bits in the stencil channel.
sizeBytesThe total byte size of the texel.
Returns
A data format descriptor in malloc'd data. The caller is responsible for freeing the descriptor.

◆ createDFDPacked()

uint32_t * createDFDPacked ( int bigEndian,
int numChannels,
int bits[],
int channels[],
enum VkSuffix suffix )

Create a Data Format Descriptor for a packed format.

Parameters
bigEndianBig-endian flag: Set to 1 for big-endian byte ordering and 0 for little-endian byte ordering.
numChannelsThe number of color channels.
bits[]An array of length numChannels. Each entry is the number of bits composing the channel, in order starting at bit 0 of the packed type.
channels[]An array of length numChannels. Each entry enumerates the channel type: 0 = red, 1 = green, 2 = blue, 15 = alpha, in order starting at bit 0 of the packed type. These values match channel IDs for RGBSDA in the Khronos Data Format header. To simplify iteration through channels, channel id 3 is a synonym for alpha.
suffixIndicates the format suffix for the type.
Returns
A data format descriptor in malloc'd data. The caller is responsible for freeing the descriptor.

◆ createDFDPackedShifted()

uint32_t * createDFDPackedShifted ( int bigEndian,
int numChannels,
int bits[],
int shiftBits[],
int channels[],
enum VkSuffix suffix )

Create a Data Format Descriptor for a packed format.

Parameters
bigEndianBig-endian flag: Set to 1 for big-endian byte ordering and 0 for little-endian byte ordering.
numChannelsThe number of color channels.
bits[]An array of length numChannels. Each entry is the number of bits composing the channel, in order starting at bit 0 of the packed type.
shiftBits[]An array of length numChannels. Each entry is the number of bits each channel is shifted and thus padded with insignificant bits.
channels[]An array of length numChannels. Each entry enumerates the channel type: 0 = red, 1 = green, 2 = blue, 15 = alpha, in order starting at bit 0 of the packed type. These values match channel IDs for RGBSDA in the Khronos Data Format header. To simplify iteration through channels, channel id 3 is a synonym for alpha.
suffixIndicates the format suffix for the type.
Returns
A data format descriptor in malloc'd data. The caller is responsible for freeing the descriptor.

◆ createDFDUnpacked()

uint32_t * createDFDUnpacked ( int bigEndian,
int numChannels,
int bytes,
int redBlueSwap,
enum VkSuffix suffix )

Create a Data Format Descriptor for an unpacked format.

Parameters
bigEndianSet to 1 for big-endian byte ordering and 0 for little-endian byte ordering.
numChannelsThe number of color channels.
bytesThe number of bytes per channel.
redBlueSwapNormally channels appear in consecutive R, G, B, A order in memory; redBlueSwap inverts red and blue, allowing B, G, R, A.
suffixIndicates the format suffix for the type.
Returns
A data format descriptor in malloc'd data. The caller is responsible for freeing the descriptor.