From d06a0c22f1617d635bde11d73223b24cd803b966 Mon Sep 17 00:00:00 2001 From: Erik Abair Date: Fri, 1 Jul 2022 12:21:42 -0700 Subject: [PATCH] nv2a: Fix incorrect use of bytes for GL_UNPACK_ROW_LENGTH `GL_UNPACK_ROW_LENGTH` is supposed to set the length in pixels, but the DXT path is setting it to bytes, causing it to read beyond the end of the texture. [Reference](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glPixelStore.xhtml) Fixes #1002 [Test](https://github.com/abaire/nxdk_pgraph_tests/blob/main/src/tests/texture_format_dxt_tests.cpp) [HW Results](https://github.com/abaire/nxdk_pgraph_tests_golden_results/wiki/Results-Texture_DXT) --- hw/xbox/nv2a/pgraph.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xbox/nv2a/pgraph.c b/hw/xbox/nv2a/pgraph.c index 657aba7027..1618c2a692 100644 --- a/hw/xbox/nv2a/pgraph.c +++ b/hw/xbox/nv2a/pgraph.c @@ -7216,7 +7216,7 @@ static void upload_gl_texture(GLenum gl_target, unsigned int physical_width = (width + 3) & ~3, physical_height = (height + 3) & ~3; if (physical_width != width) { - glPixelStorei(GL_UNPACK_ROW_LENGTH, physical_width * 4); + glPixelStorei(GL_UNPACK_ROW_LENGTH, physical_width); } uint8_t *converted = decompress_2d_texture_data( f.gl_internal_format, texture_data, physical_width,