将并行负载流式传输到着色器存储缓冲区对象
stream parallel load to Shader Storage Buffer Object
我正在尝试并行加载整数数组,但出现错误:
int[][] colors;
...
IntStream.range(0, colors.length).parallel().forEach(i -> {
GL15.glBufferSubData(GL43.GL_SHADER_STORAGE_BUFFER, pixelSIZE * i, colors[i]);
});
没有 parallel()
的实现工作正常:
IntStream.range(0, colors.length).forEach(i -> {
GL15.glBufferSubData(GL43.GL_SHADER_STORAGE_BUFFER, pixelSIZE * i, colors[i]);
});
还有for循环:
for (int i = 0; i < colors.length; i++) {
GL15.glBufferSubData(GL43.GL_SHADER_STORAGE_BUFFER, pixelSIZE * i, colors[i]);
}
错误:
[thread 13608 also had an error][thread 19708 also had an error]
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff99ca48cd9, pid=15436, tid=0x0000000000004ce8
#
# JRE version: Java(TM) SE Runtime Environment (8.0_171-b11) (build 1.8.0_171-b11)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.171-b11 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C[thread 15904 also had an error]
[thread 1456 also had an error]
[thread 19652 also had an error]
[nvoglv64.dll+0x978cd9]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# D:\Documents\NetBeansProjects\XRayInspector\hs_err_pid15436.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.
#
C:\Users\Timur\AppData\Local\NetBeans\Cache.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 19 seconds)
是否可以并行使用 glBufferSubData?
我用 lwjgl 3
OpenGL 本身是单线程的。一个 OpenGL 上下文(在某个时间点)只能与一个线程相关联。
您可以使用多个上下文(请参阅 shared context),但对于特定场景,我不确定这是否会给您带来任何性能优势,因为 GPU 很可能会序列化命令。
我正在尝试并行加载整数数组,但出现错误:
int[][] colors;
...
IntStream.range(0, colors.length).parallel().forEach(i -> {
GL15.glBufferSubData(GL43.GL_SHADER_STORAGE_BUFFER, pixelSIZE * i, colors[i]);
});
没有 parallel()
的实现工作正常:
IntStream.range(0, colors.length).forEach(i -> {
GL15.glBufferSubData(GL43.GL_SHADER_STORAGE_BUFFER, pixelSIZE * i, colors[i]);
});
还有for循环:
for (int i = 0; i < colors.length; i++) {
GL15.glBufferSubData(GL43.GL_SHADER_STORAGE_BUFFER, pixelSIZE * i, colors[i]);
}
错误:
[thread 13608 also had an error][thread 19708 also had an error]
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff99ca48cd9, pid=15436, tid=0x0000000000004ce8
#
# JRE version: Java(TM) SE Runtime Environment (8.0_171-b11) (build 1.8.0_171-b11)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.171-b11 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C[thread 15904 also had an error]
[thread 1456 also had an error]
[thread 19652 also had an error]
[nvoglv64.dll+0x978cd9]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# D:\Documents\NetBeansProjects\XRayInspector\hs_err_pid15436.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.
#
C:\Users\Timur\AppData\Local\NetBeans\Cache.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 19 seconds)
是否可以并行使用 glBufferSubData?
我用 lwjgl 3
OpenGL 本身是单线程的。一个 OpenGL 上下文(在某个时间点)只能与一个线程相关联。
您可以使用多个上下文(请参阅 shared context),但对于特定场景,我不确定这是否会给您带来任何性能优势,因为 GPU 很可能会序列化命令。