From d18e1d9a54facbabe104550f6d83e5783d3c554e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 16 Mar 2019 12:41:52 +0100 Subject: [PATCH] GL: avoid assertions due to random memory on shitty Intel Windows drivers. This code path is not run there due to the newly added "intel-windows-broken-dsa-for-cubemaps" workaround, but in case someone disables it for testing purposes the code should not randomly blow up on an assertion in compressedPixelFormatPack(). --- src/Magnum/GL/CubeMapTexture.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Magnum/GL/CubeMapTexture.cpp b/src/Magnum/GL/CubeMapTexture.cpp index cebb0b276..a57d5f9c0 100644 --- a/src/Magnum/GL/CubeMapTexture.cpp +++ b/src/Magnum/GL/CubeMapTexture.cpp @@ -223,8 +223,10 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I else dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size); - /* Internal texture format */ - GLint format; + /* Internal texture format. Zero-init to avoid an assert about value + already wrapped in compressedPixelFormatWrap() later if the drivers are + extra shitty (Intel Windows drivers, I'm talking about you). */ + GLint format{}; (this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Reallocate only if needed */ @@ -254,8 +256,10 @@ void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const I else dataSize = Magnum::Implementation::compressedImageDataSizeFor(image, size); - /* Internal texture format */ - GLint format; + /* Internal texture format. Zero-init to avoid an assert about value + already wrapped in compressedPixelFormatWrap() later if the drivers are + extra shitty (Intel Windows drivers, I'm talking about you). */ + GLint format{}; (this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Reallocate only if needed */ @@ -287,8 +291,10 @@ BufferImage3D CubeMapTexture::subImage(const Int level, const Range3Di& range, B void CubeMapTexture::compressedSubImage(const Int level, const Range3Di& range, CompressedImage3D& image) { createIfNotAlready(); - /* Internal texture format */ - GLint format; + /* Internal texture format. Zero-init to avoid an assert about value + already wrapped in compressedPixelFormatWrap() later if the drivers are + extra shitty (Intel Windows drivers, I'm talking about you). */ + GLint format{}; (this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Calculate compressed subimage size. If the user-provided pixel storage @@ -318,8 +324,10 @@ CompressedImage3D CubeMapTexture::compressedSubImage(const Int level, const Rang void CubeMapTexture::compressedSubImage(const Int level, const Range3Di& range, CompressedBufferImage3D& image, const BufferUsage usage) { createIfNotAlready(); - /* Internal texture format */ - GLint format; + /* Internal texture format. Zero-init to avoid an assert about value + already wrapped in compressedPixelFormatWrap() later if the drivers are + extra shitty (Intel Windows drivers, I'm talking about you). */ + GLint format{}; (this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Calculate compressed subimage size. If the user-provided pixel storage