@@ -747,3 +747,39 @@ uint32_t *createDFDDepthStencil(int depthBits,
747747 }
748748 return DFD ;
749749}
750+
751+ /**
752+ * @~English
753+ * @brief Create a Data Format Descriptor for an alpha-only format.
754+ *
755+ * @param bigEndian Set to 1 for big-endian byte ordering and
756+ 0 for little-endian byte ordering.
757+ * @param bytes The number of bytes per channel.
758+ * @param suffix Indicates the format suffix for the type.
759+ *
760+ * @return A data format descriptor in malloc'd data. The caller is responsible
761+ * for freeing the descriptor.
762+ **/
763+ uint32_t * createDFDAlpha (int bigEndian , int bytes ,
764+ enum VkSuffix suffix ) {
765+ uint32_t * DFD ;
766+ int channel = 3 ; /* alpha channel */
767+ if (bigEndian ) {
768+ int channelByte ;
769+ /* Number of samples = number of channels * bytes per channel */
770+ DFD = writeHeader (bytes , bytes , suffix , i_COLOR );
771+ /* Loop over the bytes that constitute a channel */
772+ for (channelByte = 0 ; channelByte < bytes ; ++ channelByte ) {
773+ writeSample (DFD , channelByte , channel ,
774+ 8 , 8 * (bytes - channelByte - 1 ),
775+ channelByte == bytes - 1 , channelByte == 0 , suffix );
776+ }
777+ } else { /* Little-endian */
778+ /* One sample per channel */
779+ DFD = writeHeader (1 , bytes , suffix , i_COLOR );
780+ writeSample (DFD , 0 , channel ,
781+ 8 * bytes , 0 ,
782+ 1 , 1 , suffix );
783+ }
784+ return DFD ;
785+ }
0 commit comments