MCPcopy Create free account
hub / github.com/KhronosGroup/KTX-Software / createDFDDepthStencil

Function createDFDDepthStencil

external/dfdutils/createdfd.c:731–773  ·  view source on GitHub ↗

* @~English * @brief Create a Data Format Descriptor for a depth-stencil format. * * @param depthBits The numeber of bits in the depth channel. * @param stencilBits The numeber of bits in the stencil channel. * @param sizeBytes The total byte size of the texel. * * @return A data format descriptor in malloc'd data. The caller is responsible * for freeing the descriptor. **/

Source from the content-addressed store, hash-verified

729 * for freeing the descriptor.
730 **/
731uint32_t *createDFDDepthStencil(int depthBits,
732 int stencilBits,
733 int sizeBytes)
734{
735 /* N.B. Little-endian is assumed. */
736 uint32_t *DFD = 0;
737 DFD = writeHeader((depthBits > 0) + (stencilBits > 0),
738 sizeBytes, s_UNORM, i_NON_COLOR);
739
740 /* Handle the special case of D24_UNORM_S8_UINT where the order of the
741 channels is flipped by putting stencil in the LSBs. */
742 if (depthBits == 24 && stencilBits == 8) {
743 writeSample(DFD, 0, KHR_DF_CHANNEL_RGBSDA_STENCIL,
744 8, 0,
745 1, 1, s_UINT);
746 writeSample(DFD, 1, KHR_DF_CHANNEL_RGBSDA_DEPTH,
747 24, 8,
748 1, 1, s_UNORM);
749 return DFD;
750 }
751
752 if (depthBits == 32) {
753 writeSample(DFD, 0, KHR_DF_CHANNEL_RGBSDA_DEPTH,
754 32, 0,
755 1, 1, s_SFLOAT);
756 } else if (depthBits > 0) {
757 writeSample(DFD, 0, KHR_DF_CHANNEL_RGBSDA_DEPTH,
758 depthBits, 0,
759 1, 1, s_UNORM);
760 }
761 if (stencilBits > 0) {
762 if (depthBits > 0) {
763 writeSample(DFD, 1, KHR_DF_CHANNEL_RGBSDA_STENCIL,
764 stencilBits, depthBits,
765 1, 1, s_UINT);
766 } else {
767 writeSample(DFD, 0, KHR_DF_CHANNEL_RGBSDA_STENCIL,
768 stencilBits, 0,
769 1, 1, s_UINT);
770 }
771 }
772 return DFD;
773}
774
775/**
776 * @~English

Callers 1

createDfd4FormatMethod · 0.85

Calls 2

writeHeaderFunction · 0.85
writeSampleFunction · 0.85

Tested by

no test coverage detected