Skip to content

Commit 5ac042b

Browse files
committed
[GL] Fixed row length when GLTexture is created.
Call to SetPixelStoreUnpack() must not be inside the conditional branch for swizzle format.
1 parent b1592d4 commit 5ac042b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sources/Renderer/OpenGL/Texture/GLTexture.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,11 +1282,15 @@ void GLTexture::AllocTextureStorage(const TextureDescriptor& textureDesc, const
12821282
/* Convert initial image data for texture swizzle formats */
12831283
ImageView intermediateImageView;
12841284

1285-
if (initialImage != nullptr && GetSwizzleFormat() == GLSwizzleFormat::BGRA)
1285+
if (initialImage != nullptr)
12861286
{
1287-
intermediateImageView = *initialImage;
1288-
intermediateImageView.format = MapSwizzleImageFormat(initialImage->format);
1289-
initialImage = &intermediateImageView;
1287+
/* Re-map image format if texture format must be emulated with component swizzling */
1288+
if (GetSwizzleFormat() == GLSwizzleFormat::BGRA)
1289+
{
1290+
intermediateImageView = *initialImage;
1291+
intermediateImageView.format = MapSwizzleImageFormat(initialImage->format);
1292+
initialImage = &intermediateImageView;
1293+
}
12901294

12911295
const GLuint srcRowLength = GetGLRowLengthOrZero(*initialImage);
12921296
GLStateManager::Get().SetPixelStoreUnpack(srcRowLength, textureDesc.extent.height, 1);

0 commit comments

Comments
 (0)