opengl - OpenGL驱动程序在glTexture2D上崩溃

标签 opengl crash driver lwjgl

使用以下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:\Users\Antonio\Documents\IdeaProjects\VideoStudio\hs_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之前。

关于opengl - OpenGL驱动程序在glTexture2D上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62285277/

相关文章:

c++ - 编译器提供语法错误,Visual Studio中未显示。我能做什么?

c - 内核代码如何知道正在使用哪个 spi 总线?

OpenGL 使用对数坐标轴

java - 渲染不同的VAO

python - 使用 sess.run() 时 Tensorflow 崩溃

vba - 每次我使用即时窗口时 MS Access 都会崩溃

android - 将驱动程序添加到 Android 设备内核

c - 确定驱动模块所在的位置(内存地址)

opengl - glsl double 顶点缓冲区

python - 尝试创建列表时python crashes(?)