amonakov / primus

Low-overhead client-side GPU offloading
ISC License
216 stars 20 forks source link

Attempting to use Viewport 2.0 in Maya causes crash #55

Closed chippey closed 11 years ago

chippey commented 11 years ago

Switching to Viewport 2.0 ("Renderer" menu --> "Viewport 2.0") causes Maya to crash

 primusrun maya
Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 9: reading configurations from ~/.fonts.conf is deprecated.

Xlib:  extension "NV-GLX" missing on display ":0".
primus: sorry, not implemented: glXUseXFont

maya encountered a fatal error

Signal: 11 (Unknown Signal)
Stack trace:
  /lib/x86_64-linux-gnu/libc.so.6(+0x364a0) [0x7f2f492e44a0]
  OGSMayaVramQuery::queryVramOGL()
  OGSMayaVramQuery::OGSMayaVramQuery()
  OGSMayaVramQuery::getInstance()
  OGSMayaVramQuery::queryVram()
  OGSRenderer::getTotalGPUMemory()
  OGSRenderer::initializeOGSDevice(OGS::Objects::UString*, int)
  OGSMayaRenderer::initialize(bool, unsigned int, int, void*, void*, void*, bool)
  OGSMayaBridge::CreateOGSRenderer()
  OGSMayaBaseRenderer::initialize()
  OGSViewportRenderer::initialize()
  TidleRefreshCmd::refreshOGSRender(T3dView*, bool, bool, TdisplayAppearance, bool, bool, bool)
  TidleRefreshCmd::refresh(T3dView*, TdisplayAppearance, bool, bool, bool, bool, TrefreshType, bool, bool)
  TidleRefreshCmd::doIt(Tevent const&)
  TeventHandler::doIdles()
  QObject::event(QEvent*)
  QidleTimer::event(QEvent*)
  QApplicationPrivate::notify_helper(QObject*, QEvent*)
  QApplication::notify(QObject*, QEvent*)
  QmayaApplication::notify(QObject*, QEvent*)
  QCoreApplication::notifyInternal(QObject*, QEvent*)
...
amonakov commented 11 years ago

The likely problem here is that Maya uses NVControl to get GPU attributes (such as Video RAM size in the backtrace above), but the queries fail because it passes :0 as X Display, while the GPU is actually on the :8 secondary Bumblebee X server. Maya probably does not expect them to fail, and passes an unchecked pointer to some libc function, causing a segfault. I don't think this is something Autodesk will hurry to fix.

To cure this, someone has to write a very simple interposer library to redirect displays in NVControl requests (the fact that Display pointers are passed both as arguments and struct fields is slightly annoying).

chippey commented 11 years ago

I don't know if this is a relevant thought or not, but is there some sort of env var that accomplishes the equivalent to the -c flag for nvidia-settings (I haven't yet dug though google and docs to see yet if there is)? If there is, would it work to set that in the primusrun script?

(Side note, setting -c works using optirun (optirun nvidia-settings -c :8 ), but not primusrun. I'll open a new issue for that, but I don't know how important it really is)

amonakov commented 11 years ago

but is there some sort of env var that accomplishes the equivalent to the -c flag for nvidia-settings

No, that's improbable. If it exists, however, you should be looking in Maya docs; it wouldn't make much technical sense to provide an override in the drivers.

chippey commented 11 years ago

Yeah, couldn't find anything - was a long shot in any case. I almost got my hopes up looking through the Maya docs, as there is a env var that's named something that sounds relevant (MAYA_VP2_DEVICE_OVERRIDE), but it turns out it's for forcing either a dx11 or opengl backend for Viewport 2.0. Damn.