Skip to content

Commit

Permalink
X11 Trans: Reuse 3D app's X conn(s) if VGL_SYNC=1
Browse files Browse the repository at this point in the history
  • Loading branch information
dcommander committed Dec 5, 2024
1 parent f32c6a1 commit 7abaf20
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ not added to the list of extensions returned by
`glXQueryServerString(..., GLX_EXTENSIONS)` unless the underlying EGL
implementation supported v1.5 or later of the EGL API.

2. If `VGL_SYNC` is enabled, the X11 Transport now reuses the 3D application's
X display connection(s), which may prevent a 3D application running with
VirtualGL from exceeding the X server's connection limit if the application
opens an excessive number of OpenGL windows.


3.1.1
=====
Expand Down
10 changes: 10 additions & 0 deletions doc/advancedconfig.txt
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,16 @@ previous method:
machine other than the VirtualGL server. It is strongly recommended that
''VGL_SYNC'' be used only in conjunction with an X proxy running on the
VirtualGL server.
{nl}{nl}
In order to implement frame spoiling, and also to allow the last frame to be
transported while the current frame is being rendered and read back,
VirtualGL's built-in image transports use a separate "transport thread". To
ensure thread safety, the X11 Transport normally creates multiple X display
connections for each OpenGL window. However, when ''VGL_SYNC'' is enabled,
the X11 Transport instead reuses the 3D application's X display
connection(s). Thus, enabling ''VGL_SYNC'' may prevent a 3D application
running with VirtualGL from exceeding the X server's connection limit if the
application opens an excessive number of OpenGL windows.

!!! If an image transport plugin is being used, then VirtualGL does not
automatically enable the X11 Transport or disable frame spoiling when
Expand Down
14 changes: 12 additions & 2 deletions doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta name="language" content="en">
<meta name="date" content="2024-12-05T18:20:16">
<meta name="date" content="2024-12-05T18:20:52">
<meta name="generator" content="deplate.rb 0.8.5">
<title>User&rsquo;s Guide for VirtualGL 3.1.2</title>
<link rel="start" href="index.html" title="Frontpage">
Expand Down Expand Up @@ -4423,7 +4423,17 @@ <h2 id="hd0018001">18.1&nbsp;Faker Settings</h2>
potentially dire effects on performance when used with a 2D X server on
a machine other than the VirtualGL server. It is strongly recommended
that <code>VGL_SYNC</code> be used only in conjunction with an X proxy
running on the VirtualGL server.
running on the VirtualGL server. <br /><br /> In order to implement
frame spoiling, and also to allow the last frame to be transported while
the current frame is being rendered and read back, VirtualGL&rsquo;s
built-in image transports use a separate &ldquo;transport thread&rdquo;.
To ensure thread safety, the X11 Transport normally creates multiple X
display connections for each OpenGL window. However, when
<code>VGL_SYNC</code> is enabled, the X11 Transport instead reuses the
3D application&rsquo;s X display connection(s). Thus, enabling
<code>VGL_SYNC</code> may prevent a 3D application running with
VirtualGL from exceeding the X server&rsquo;s connection limit if the
application opens an excessive number of OpenGL windows.
<div class="important"><p class="important">
If an image transport plugin is being used, then VirtualGL does not automatically enable the X11 Transport or disable frame spoiling when <code>VGL_SYNC</code> is set. This allows the plugin to handle synchronous image delivery as it sees fit (or to simply ignore this option.)
</p></div>
Expand Down
9 changes: 5 additions & 4 deletions server/X11Trans.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C)2004 Landmark Graphics Corporation
// Copyright (C)2005, 2006 Sun Microsystems, Inc.
// Copyright (C)2010-2011, 2014, 2019-2021 D. R. Commander
// Copyright (C)2010-2011, 2014, 2019-2021, 2024 D. R. Commander
//
// This library is free software and may be redistributed and/or modified under
// the terms of the wxWindows Library License, Version 3.1 or (at your option)
Expand Down Expand Up @@ -31,7 +31,8 @@ using namespace server;

X11Trans::X11Trans(void) : thread(NULL), deadYet(false)
{
for(int i = 0; i < NFRAMES; i++) frames[i] = NULL;
if(fconfig.sync) nFrames = 1;
for(int i = 0; i < nFrames; i++) frames[i] = NULL;
thread = new Thread(this);
thread->start();
profBlit.setName("Blit ");
Expand Down Expand Up @@ -116,12 +117,12 @@ FBXFrame *X11Trans::getFrame(Display *dpy, Window win, int width, int height)
CriticalSection::SafeLock l(mutex);

int index = -1;
for(int i = 0; i < NFRAMES; i++)
for(int i = 0; i < nFrames; i++)
if(!frames[i] || (frames[i] && frames[i]->isComplete()))
index = i;
if(index < 0) THROW("No free buffers in pool");
if(!frames[index])
frames[index] = new FBXFrame(dpy, win);
frames[index] = new FBXFrame(dpy, win, NULL, fconfig.sync);
f = frames[index]; f->waitUntilComplete();
}

Expand Down
8 changes: 4 additions & 4 deletions server/X11Trans.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C)2004 Landmark Graphics Corporation
// Copyright (C)2005, 2006 Sun Microsystems, Inc.
// Copyright (C)2010-2011, 2014, 2021 D. R. Commander
// Copyright (C)2010-2011, 2014, 2021, 2024 D. R. Commander
//
// This library is free software and may be redistributed and/or modified under
// the terms of the wxWindows Library License, Version 3.1 or (at your option)
Expand Down Expand Up @@ -34,7 +34,7 @@ namespace server
deadYet = true;
q.release();
if(thread) { thread->stop(); delete thread; thread = NULL; }
for(int i = 0; i < NFRAMES; i++)
for(int i = 0; i < nFrames; i++)
{
delete frames[i]; frames[i] = NULL;
}
Expand All @@ -49,9 +49,9 @@ namespace server

private:

static const int NFRAMES = 3;
int nFrames = 3;
util::CriticalSection mutex;
common::FBXFrame *frames[NFRAMES];
common::FBXFrame *frames[3];
util::Event ready;
util::GenericQ q;
util::Thread *thread;
Expand Down

0 comments on commit 7abaf20

Please sign in to comment.