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

Utility for interpreting a data format descriptor. More...

#include <stdint.h>
#include <stdio.h>
#include <KHR/khr_df.h>
#include "dfd.h"

Functions

enum InterpretDFDResult interpretDFD (const uint32_t *DFD, InterpretedDFDChannel *R, InterpretedDFDChannel *G, InterpretedDFDChannel *B, InterpretedDFDChannel *A, uint32_t *wordBytes)
 Interpret a Data Format Descriptor for a simple format.

Detailed Description

Utility for interpreting a data format descriptor.

Author
Andrew Garrard

Function Documentation

◆ interpretDFD()

enum InterpretDFDResult interpretDFD ( const uint32_t * DFD,
InterpretedDFDChannel * R,
InterpretedDFDChannel * G,
InterpretedDFDChannel * B,
InterpretedDFDChannel * A,
uint32_t * wordBytes )

Interpret a Data Format Descriptor for a simple format.

Handles "simple" cases that can be translated to things a GPU can access. For simplicity, it ignores the compressed formats, which are generally a single sample (and I believe are all defined to be little-endian in their in-memory layout, even if some documentation confuses this). Focuses on the layout and ignores sRGB except for reporting if that is the transfer function by way of a bit in the returned value.

Parameters
[in]DFDPointer to a Data Format Descriptor to interpret, described as 32-bit words in native endianness. Note that this is the whole descriptor, not just the basic descriptor block.
R[in,out]Pointer to struct to receive information about the decoded red channel, the Y channel, if YUV, or the depth channel, if any.
G[in,out]Pointer to struct to receive information about the decoded green channel, the U (Cb) channel, if YUV, or the stencil channel, if any.
B[in,out]Pointer to struct to receive information about the decoded blue channel, if any or the V (Cr) channel, if YUV.
A[in,out]Pointer to struct to receive information about the decoded alpha channel, if any or the second Y channel, if YUV and any.
wordBytes[in,out]Pointer to a uint32_t to receive the byte size of the channels (unpacked) or total size (packed).
Returns
An enumerant describing the decoded value, or an error code in case of failure.

The mapping of YUV channels to the parameter names used here is based on the channel ids in khr_df.h and is different from the convention used in format names in the Vulkan specification where G == Y, R = Cr and B = Cb.