MCPcopy Create free account
hub / github.com/baldurk/renderdoc / write_dds_to_file

Function write_dds_to_file

renderdoc/common/dds_readwrite.cpp:676–953  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

674}
675
676RDResult write_dds_to_file(FILE *f, const write_tex_data &data)
677{
678 if(!f)
679 return RDResult(ResultCode::InvalidParameter, "Missing file handle writing DDS file");
680
681 uint32_t magic = dds_fourcc;
682 DDS_HEADER header;
683 DDS_HEADER_DXT10 headerDXT10;
684 RDCEraseEl(header);
685 RDCEraseEl(headerDXT10);
686
687 header.dwSize = sizeof(DDS_HEADER);
688
689 header.ddspf.dwSize = sizeof(DDS_PIXELFORMAT);
690
691 header.dwWidth = data.width;
692 header.dwHeight = data.height;
693 header.dwDepth = data.depth;
694 header.dwMipMapCount = data.mips;
695
696 header.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
697 if(data.mips > 1)
698 header.dwFlags |= DDSD_MIPMAPCOUNT;
699 if(data.depth > 1)
700 header.dwFlags |= DDSD_DEPTH;
701
702 bool blockFormat = false;
703
704 if(data.format.Special())
705 {
706 switch(data.format.type)
707 {
708 case ResourceFormatType::BC1:
709 case ResourceFormatType::BC2:
710 case ResourceFormatType::BC3:
711 case ResourceFormatType::BC4:
712 case ResourceFormatType::BC5:
713 case ResourceFormatType::BC6:
714 case ResourceFormatType::BC7: blockFormat = true; break;
715 case ResourceFormatType::ETC2:
716 case ResourceFormatType::EAC:
717 case ResourceFormatType::ASTC:
718 case ResourceFormatType::YUV8:
719 case ResourceFormatType::YUV10:
720 case ResourceFormatType::YUV12:
721 case ResourceFormatType::YUV16:
722 {
723 RETURN_ERROR_RESULT(ResultCode::ImageUnsupported,
724 "Unsupported file format %s to write to DDS",
725 ToStr(data.format.type).c_str());
726 }
727 default: break;
728 }
729 }
730
731 if(blockFormat)
732 header.dwFlags |= DDSD_LINEARSIZE;
733 else

Callers 1

SaveTextureMethod · 0.85

Calls 8

RDResultClass · 0.85
ToStrFunction · 0.85
RDCMAXFunction · 0.85
NameMethod · 0.80
swapFunction · 0.50
fwriteFunction · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected