Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (575)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How to get SLI (and Crossfire?) working with framebuffer objects  (Read 1420 times)
0 Members and 1 Guest are viewing this topic.
Offline theagentd
« Posted 2013-01-30 16:55:38 »

This is a tutorial covering how to get SLI (and presumably Crossfire) working with your OpenGL based game!

SLI and Crossfire are technologies of Nvidia and AMD respectively that enable users to cram in multiple GPUs into their computers and have them work in parallel to give (hopefully) almost linear scaling with the number of GPUs. In practice there are some problems, for example driver compatibility problems and micro-stuttering, but there sure are some heavy FPS wins possible. For good performance, the single one thing you have to avoid is data-dependency between frames. Since I have an Nvidia Geforce GTX 295, I can't tell you exactly how to do this with a Crossfire setup, but it should be doable to AMD drivers as well.

Enabling SLI for your game is easy as pie with Nvidia cards and can be done without any third-party programs like Nvidia Inspector.

1. Double-click the Nvidia icon on your tray bar to fire up the Nvidia Control Panel.
2. In the left-most panel, go to "Manage 3D settings" (under "3D settings").

Now, do either 3a or 3b:
3a. (the lazy way) In the Global Settings tab, find "SLI performance mode" and set it to "Force alternative frame rendering 2". This will enable SLI for all programs using DirectX or OpenGL, so remember to disable it after you're done!
3b. (the right way) Go to Program Settings and create a profile for java.exe and javaw.exe. Then find "SLI performance mode" and set it to "Force alternative frame rendering 2". This will only enable it for Java programs, but it might still screw up Java2D OpenGL acceleration if you're unlucky...

4. Run your Java program and enjoy much higher frame rates!


For most of you, that'll all you need to do. However, if you're using FBOs for anything (shadow maps, offscreen rendering, whatever) you'll notice that instead of a 90% performance boost, you got a 75% performance penalty!!! Surely there's something fishy going on here.

The problem is that since there's no hand-made SLI profile made for your game by Nvidia, the driver makes assumptions. In our case, bad assumptions. FBOs effectively cause your GPU to generate a texture on its own. Alternative frame rendering (AFR) makes each GPU work on every other frame. Therefore when we finish a frame, all render target textures are synchronized between all GPUs to ensure that they all have the generated textures, and there goes our parallelism. Not only can the GPUs not work in parallel at all, the copying overhead completely kills our frame-rate.

Our savior is an OpenGL extension called ARBInvalidateSubdata! This extension allows you to invalidate the contents of a texture, framebuffer or texture! At the end of the frame, just before we complete a frame and do a buffer swap, we invalidate all textures that we've rendered to that aren't needed in the next frame! That tells the driver that those textures won't need to be synchronized between GPUs, so we get perfect scaling!

Myomyomyo.
Offline sproingie

JGO Kernel


Medals: 202



« Reply #1 - Posted 2013-01-31 02:45:41 »

Medal for you even though my puissant wit is no longer immortalized in your sig Wink
Offline ra4king

JGO Kernel


Medals: 353
Projects: 3
Exp: 5 years


I'm the King!


« Reply #2 - Posted 2013-01-31 03:51:14 »

Noooo our precious signature joke! Sad

Great post! I'm going to look into that and play with it Cheesy

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline theagentd
« Reply #3 - Posted 2013-01-31 10:44:00 »

Yeah, I realized my new one definitely isn't as funny when brought out of context...

Myomyomyo.
Offline theagentd
« Reply #4 - Posted 2013-01-31 16:59:06 »

Some numbers from my testing (god, I love numbers):

Single GPU: 89 FPS (1.00x)
2 GPU AFR2: 46 FPS (0.52x)
2 GPU AFR2 /w glInvalidateTexImage(): 166 FPS (1.93x)

In this program I invalidate 4 textures used as render targets before swapping the buffers. The textures are are 3x 64bpp RGBA16F textures and 1x 32bpp depth-stencil texture. At 1920x1080 and 166 FPS, that's almost 9GBs of data copying avoided PER SECOND. It should also be noted that glInvalidateTexImage() is NOT the same as glClear(). glInvalidateTexImage() just marks the texture "invalid" and therefore doesn't have a measurable cost. It simply gives the driver enough information to allow it to do the necessary optimizations needed for AFR to work properly.

Myomyomyo.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (33 views)
2014-10-17 03:59:02

Norakomi (25 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (26 views)
2014-10-15 16:18:58

TehJavaDev (50 views)
2014-10-14 00:39:48

TehJavaDev (50 views)
2014-10-14 00:35:47

TehJavaDev (40 views)
2014-10-14 00:32:37

BurntPizza (63 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (74 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!