| 52 | } |
| 53 | |
| 54 | bool WriteDdsHeader(ntc::IStream* ddsFile, int width, int height, int mipLevels, BcFormatDefinition const* outputFormatDefinition, ntc::ColorSpace colorSpace) |
| 55 | { |
| 56 | using namespace donut::engine::dds; |
| 57 | DDS_HEADER ddsHeader{}; |
| 58 | DDS_HEADER_DXT10 dx10header = {}; |
| 59 | ddsHeader.size = sizeof(DDS_HEADER); |
| 60 | ddsHeader.flags = DDS_HEADER_FLAGS_TEXTURE; |
| 61 | ddsHeader.width = width; |
| 62 | ddsHeader.height = height; |
| 63 | ddsHeader.depth = 1; |
| 64 | ddsHeader.mipMapCount = mipLevels; |
| 65 | ddsHeader.ddspf.size = sizeof(DDS_PIXELFORMAT); |
| 66 | ddsHeader.ddspf.flags = DDS_FOURCC; |
| 67 | ddsHeader.ddspf.fourCC = MAKEFOURCC('D', 'X', '1', '0'); |
| 68 | dx10header.resourceDimension = DDS_DIMENSION_TEXTURE2D; |
| 69 | dx10header.arraySize = 1; |
| 70 | dx10header.dxgiFormat = colorSpace == ntc::ColorSpace::sRGB ? outputFormatDefinition->dxgiFormatSrgb : outputFormatDefinition->dxgiFormat; |
| 71 | |
| 72 | uint32_t ddsMagic = DDS_MAGIC; |
| 73 | bool success; |
| 74 | success = ddsFile->Write(&ddsMagic, sizeof(ddsMagic)); |
| 75 | success &= ddsFile->Write(&ddsHeader, sizeof(ddsHeader)); |
| 76 | success &= ddsFile->Write(&dx10header, sizeof(dx10header)); |
| 77 | return success; |
| 78 | } |
| 79 | |
| 80 | bool SavePNG(uint8_t* data, int mipWidth, int mipHeight, int numChannels, bool is16Bit, char const* fileName) |
| 81 | { |
no outgoing calls
no test coverage detected