gpt4 book ai didi

c++ - 在多个显示器上使用 GLX RHEL -- OpenGL、XLib 和多个显示器(带线程)

转载 作者:行者123 更新时间:2023-11-28 08:09:35 28 4
gpt4 key购买 nike

我面临的问题是我有一个基于 glx 的应用程序,它可以在单个线程上很好地渲染基本图元。我可以在两个屏幕之间移动 XWindow,我的渲染循环继续进行。但是,如果我的应用程序的任何部分有线程,即使它没有进行任何 openGL 调用或在任何其他线程上接触 XWindow 但主线程,当我将 XWindow 从一个屏幕移动到另一个屏幕时,我渲染的图形就会丢失。

我进行的第一个函数调用是 XInitThreads,因此我知道 X11 应该是线程安全的。正如我所说,这在一个线程上绘制图元时有效,但当我添加 1 个或多个线程时它不起作用。这些线程位于我无权访问源代码的库中。我只是被要求使用 X11 创建代码的窗口部分。

我应该寻找什么来解决这个问题?

另请注意,我已经保证所有 glcalls 都发生在我从库内部调用它们的线程上。


更新

[matt6809@hogganz400 SampleApp]$ cat /etc/X11/xorg.conf && echo "--------" && xrandr --verbose && echo "-------" && glxinfo && echo "-------" && xdpyinfo
# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings: version 295.20 (buildmeister@swio-display-x86-rhel47-05.nvidia.com) Mon Feb 6 22:13:16 PST 2012

# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig: version 295.20 (buildmeister@swio-display-x86-rhel47-05.nvidia.com) Mon Feb 6 22:13:40 PST 2012

Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0" 0 0
Screen 1 "Screen1" RightOf "Screen0"
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
Option "Xinerama" "1"
EndSection

Section "Files"
FontPath "/usr/share/fonts/default/Type1"
EndSection

Section "InputDevice"

# generated from default
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/input/mice"
Option "Emulate3Buttons" "no"
Option "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"

# generated from data in "/etc/sysconfig/keyboard"
Identifier "Keyboard0"
Driver "kbd"
Option "XkbLayout" "us"
Option "XkbModel" "pc105"
EndSection

Section "Monitor"
Identifier "Monitor0"
VendorName "Unknown"
ModelName "DELL P190S"
HorizSync 30.0 - 81.0
VertRefresh 56.0 - 76.0
Option "DPMS"
EndSection

Section "Monitor"
Identifier "Monitor1"
VendorName "Unknown"
ModelName "DELL P190S"
HorizSync 30.0 - 81.0
VertRefresh 56.0 - 76.0
Option "DPMS"
EndSection

Section "Monitor"
Identifier "Monitor1"
VendorName "Unknown"
ModelName "DELL 1908FP"
HorizSync 31.0 - 83.0
VertRefresh 56.0 - 76.0
EndSection

Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "Quadro 4000"
BusID "PCI:15:0:0"
Screen 0
EndSection

Section "Device"
Identifier "Device1"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "Quadro 4000"
BusID "PCI:15:0:0"
Screen 1
EndSection

Section "Screen"
Identifier "Screen0"
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24
Option "TwinView" "0"
Option "TwinViewXineramaInfoOrder" "DFP-0"
Option "metamodes" "DFP-0: nvidia-auto-select +0+0"
SubSection "Display"
Depth 24
EndSubSection
EndSection

Section "Screen"
Identifier "Screen1"
Device "Device1"
Monitor "Monitor1"
DefaultDepth 24
Option "TwinView" "0"
Option "metamodes" "DFP-2: nvidia-auto-select +0+0"
SubSection "Display"
Depth 24
EndSubSection
EndSection

--------
Xlib: extension "RANDR" missing on display ":0.0".
RandR extension missing
[matt6809@hogganz400 SampleApp]$

最佳答案

这只是一种预感,但也可能是 OpenGL 上下文没有在线程之间完全迁移。如果您可以完全控制 OpenGL 和窗口操作,您的问题并不清楚。

涉及 OpenGL 和多线程时,通常的方法是将所有 OpenGL 操作限制在一个特定的线程中。

如果你不能确定这一点,你应该打电话

glXMakeContextCurrent(display, None, None, NULL); // GLX 1.3

glXMakeCurrent(display, None, NULL); // GLX 1.2 and earlier

在屈服于另一个线程或完成 tasklet 之前完成 OpenGL 操作之后,以确保上下文与当前线程正确解除绑定(bind)。

在需要时相应地重新绑定(bind)上下文。

关于c++ - 在多个显示器上使用 GLX RHEL -- OpenGL、XLib 和多个显示器(带线程),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9472210/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com