OpenGL 驱动程序在 glTexture2D 上崩溃



使用以下Kotlin/JVM/LWJGL + java.nio.ByteBuffer + OpenGL代码,似乎我可以崩溃我的一些驱动程序:

val texture = glGenTextures()
glBindTexture(GL_TEXTURE_2D, texture)
val w = 1026
val h = 1029
val byteBuffer = ByteBuffer
.allocateDirect(w*h)
.position(0)
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, byteBuffer)

在通常的 GLFW+OpenGL 初始化之后执行此操作,这会导致应用程序崩溃并显示以下消息:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff98593509c, pid=13572, tid=15424
#
# JRE version: OpenJDK Runtime Environment (12.0.1+12) (build 12.0.1+12)
# Java VM: OpenJDK 64-Bit Server VM (12.0.1+12, mixed mode, sharing, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# C  [atio6axx.dll+0x1bb509c]
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:UsersAntonioDocumentsIdeaProjectsVideoStudiohs_err_pid13572.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

我能做些什么,但要避免非 2 次幂纹理?

我测试了一些分辨率,只有宽度或高度> 1024 的纹理崩溃。 在 1026 x 1029(以及更多,例如 1590 x 2244(的情况下,我在 100% 的情况下崩溃。

我正在使用RX 580,R5 2600,Win 10,Radeon驱动程序更新为推荐,以防万一它会改变某些内容。

图像数据中行的默认对齐方式为 4 个字节。除非纹理的宽度是 4 的倍数,否则您必须在每行末尾提供额外的字节进行填充。

另一种选择是通过调用将解包对齐方式更改为 1 字节

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

在打电话给glTexImage2D之前.

最新更新