| 5722 | } |
| 5723 | |
| 5724 | static int32_t imageWriteDdsHeader(bx::WriterI* _writer, TextureFormat::Enum _format, bool _cubeMap, uint32_t _width, uint32_t _height, uint32_t _depth, uint8_t _numMips, uint32_t _numLayers, bx::Error* _err) |
| 5725 | { |
| 5726 | BX_ERROR_SCOPE(_err); |
| 5727 | |
| 5728 | uint32_t ddspf = UINT32_MAX; |
| 5729 | uint32_t dxgiFormat = UINT32_MAX; |
| 5730 | uint32_t fourccFormat = UINT32_MAX; |
| 5731 | |
| 5732 | for (uint32_t ii = 0; ii < BX_COUNTOF(s_translateDdsPixelFormat); ++ii) |
| 5733 | { |
| 5734 | if (s_translateDdsPixelFormat[ii].m_textureFormat == _format) |
| 5735 | { |
| 5736 | ddspf = ii; |
| 5737 | break; |
| 5738 | } |
| 5739 | } |
| 5740 | |
| 5741 | if (UINT32_MAX == ddspf) |
| 5742 | { |
| 5743 | for (uint32_t ii = 0; ii < BX_COUNTOF(s_translateDxgiFormat); ++ii) |
| 5744 | { |
| 5745 | if (s_translateDxgiFormat[ii].m_textureFormat == _format) |
| 5746 | { |
| 5747 | dxgiFormat = s_translateDxgiFormat[ii].m_format; |
| 5748 | break; |
| 5749 | } |
| 5750 | } |
| 5751 | } |
| 5752 | |
| 5753 | if (UINT32_MAX == ddspf && UINT32_MAX == dxgiFormat) |
| 5754 | { |
| 5755 | for (uint32_t ii = 0; ii < BX_COUNTOF(s_translateDdsFourccFormat); ++ii) |
| 5756 | { |
| 5757 | if (s_translateDdsFourccFormat[ii].m_textureFormat == _format) |
| 5758 | { |
| 5759 | fourccFormat = s_translateDdsFourccFormat[ii].m_format; |
| 5760 | break; |
| 5761 | } |
| 5762 | } |
| 5763 | } |
| 5764 | |
| 5765 | if (UINT32_MAX == ddspf |
| 5766 | && UINT32_MAX == dxgiFormat |
| 5767 | && UINT32_MAX == fourccFormat) |
| 5768 | { |
| 5769 | BX_ERROR_SET(_err, BIMG_ERROR, "DDS: output format not supported."); |
| 5770 | return 0; |
| 5771 | } |
| 5772 | |
| 5773 | const uint32_t bpp = getBitsPerPixel(_format); |
| 5774 | |
| 5775 | uint32_t total = 0; |
| 5776 | total += bx::write(_writer, uint32_t(DDS_MAGIC), _err); |
| 5777 | |
| 5778 | uint32_t headerStart = total; |
| 5779 | total += bx::write(_writer, uint32_t(DDS_HEADER_SIZE), _err); |
| 5780 | total += bx::write(_writer, uint32_t(0 |
| 5781 | | DDSD_HEIGHT |
no test coverage detected