MCPcopy Create free account
hub / github.com/DentonW/DevIL / AdjustVolumeTexture

Function AdjustVolumeTexture

DevIL/src-IL/src/il_dds.cpp:570–626  ·  view source on GitHub ↗

The few volume textures that I have don't have consistent LinearSize entries, even though the DDS_LINEARSIZE flag is set.

Source from the content-addressed store, hash-verified

568// The few volume textures that I have don't have consistent LinearSize
569// entries, even though the DDS_LINEARSIZE flag is set.
570void AdjustVolumeTexture(DDSHEAD *Head, ILuint CompFormat)
571{
572 if (Head->Depth <= 1)
573 return;
574
575 // All volume textures I've seem so far didn't have the DDS_COMPLEX flag set,
576 // even though this is normally required. But because noone does set it,
577 // also read images without it (TODO: check file size for 3d texture?)
578 if (/*!(Head->ddsCaps1 & DDS_COMPLEX) ||*/ !(Head->ddsCaps2 & DDS_VOLUME)) {
579 Head->Depth = 1;
580 Depth = 1;
581 }
582
583 switch (CompFormat)
584 {
585 case PF_ARGB:
586 case PF_RGB:
587 case PF_LUMINANCE:
588 case PF_LUMINANCE_ALPHA:
589 //don't use the iCompFormatToBpp() function because this way
590 //argb images with only 8 bits (eg. a1r2g3b2) work as well
591 Head->LinearSize = IL_MAX(1,Head->Width) * IL_MAX(1,Head->Height) *
592 (Head->RGBBitCount / 8);
593 break;
594
595 case PF_DXT1:
596
597 case PF_ATI1N:
598 Head->LinearSize = ((Head->Width+3)/4) * ((Head->Height+3)/4) * 8;
599 break;
600
601 case PF_DXT2:
602 case PF_DXT3:
603 case PF_DXT4:
604 case PF_DXT5:
605 case PF_3DC:
606 case PF_RXGB:
607 Head->LinearSize = ((Head->Width+3)/4) * ((Head->Height+3)/4) * 16;
608 break;
609
610 case PF_A16B16G16R16:
611 case PF_R16F:
612 case PF_G16R16F:
613 case PF_A16B16G16R16F:
614 case PF_R32F:
615 case PF_G32R32F:
616 case PF_A32B32G32R32F:
617 Head->LinearSize = IL_MAX(1,Head->Width) * IL_MAX(1,Head->Height) *
618 iCompFormatToBpp(CompFormat);
619 break;
620 }
621
622 Head->Flags1 |= DDS_LINEARSIZE;
623 Head->LinearSize *= Head->Depth;
624
625 return;
626}
627

Callers 1

iLoadDdsInternalFunction · 0.85

Calls 1

iCompFormatToBppFunction · 0.85

Tested by

no test coverage detected