mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-04-24 02:32:18 +00:00
Respect binary file row pitch for reading and uploading DXT1/DXT5 compressed mip images
This commit is contained in:
parent
ad046923f5
commit
2726e6ae29
3 changed files with 5 additions and 5 deletions
|
@ -906,9 +906,9 @@ bool idBinaryImage::LoadFromGeneratedFile( idFile* bFile, ID_TIME_T sourceTimeSt
|
|||
// SRS - For compressed formats, match allocation to what nvrhi expects for the texture's mip variants
|
||||
else if( ( textureFormat_t )fileData.format == FMT_DXT1 || ( textureFormat_t )fileData.format == FMT_DXT5 )
|
||||
{
|
||||
int mipCols = ( ( ( ( fileData.width + 3 ) & ~3 ) >> img.level ) + 3 ) / 4;
|
||||
int rowPitch = GetRowPitch( ( textureFormat_t )fileData.format, img.width );
|
||||
int mipRows = ( ( ( ( fileData.height + 3 ) & ~3 ) >> img.level ) + 3 ) / 4;
|
||||
img.Alloc( Max( img.dataSize, mipCols * mipRows * BlockSizeForFormat( ( textureFormat_t )fileData.format ) ) );
|
||||
img.Alloc( Max( img.dataSize, rowPitch * mipRows ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -114,7 +114,7 @@ enum textureFormat_t
|
|||
};
|
||||
|
||||
int BitsForFormat( textureFormat_t format );
|
||||
int BlockSizeForFormat( const textureFormat_t& format );
|
||||
int GetRowPitch( const textureFormat_t& format, int width );
|
||||
|
||||
/*
|
||||
================================================
|
||||
|
|
|
@ -120,7 +120,7 @@ GetRowBytes
|
|||
Returns the row bytes for the given image.
|
||||
=========================
|
||||
*/
|
||||
static int GetRowPitch( const textureFormat_t& format, int width )
|
||||
int GetRowPitch( const textureFormat_t& format, int width )
|
||||
{
|
||||
bool bc = ( format == FMT_DXT1 || format == FMT_DXT5 );
|
||||
|
||||
|
@ -718,7 +718,7 @@ void idImage::FinalizeImage( bool fromBackEnd, nvrhi::ICommandList* commandList
|
|||
bufferW = ( img.width + 3 ) & ~3;
|
||||
}
|
||||
|
||||
commandList->writeTexture( texture, img.destZ, img.level, pic, GetRowPitch( opts.format, bufferW ) );
|
||||
commandList->writeTexture( texture, img.destZ, img.level, pic, GetRowPitch( opts.format, img.width ) );
|
||||
}
|
||||
}
|
||||
commandList->setPermanentTextureState( texture, nvrhi::ResourceStates::ShaderResource );
|
||||
|
|
Loading…
Reference in a new issue