diff --git a/neo/renderer/BinaryImage.cpp b/neo/renderer/BinaryImage.cpp index 8b25b2a2..1ab0f1dd 100644 --- a/neo/renderer/BinaryImage.cpp +++ b/neo/renderer/BinaryImage.cpp @@ -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 { diff --git a/neo/renderer/Image.h b/neo/renderer/Image.h index e7167409..fce19a08 100644 --- a/neo/renderer/Image.h +++ b/neo/renderer/Image.h @@ -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 ); /* ================================================ diff --git a/neo/renderer/Image_load.cpp b/neo/renderer/Image_load.cpp index e59db057..7bd3b55b 100644 --- a/neo/renderer/Image_load.cpp +++ b/neo/renderer/Image_load.cpp @@ -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 );