Pages: [1] 2 3
  Print  
Author Topic: 1,000,000 Cubes  (Read 8293 times)
Offline (Male) Goombert
Posted on: May 24, 2013, 07:02:59 PM

Contributor
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2988

View Profile


As you are all aware we are boosting the performance of the OpenGL3 graphics system, doing a simple test with 100^3=1,000,000 cubes with a GLSL shader and other techniques at a solid framerate. Download and see for yourself!  :D

Download: https://www.dropbox.com/s/n7nop33tvq47upx/Hardware%20Performance%20Evaluator.zip
Size: 6.74mb's

***** Instructions *****
1) Go into obj_gamestate and look for where I load the two shader scripts, modify the string value to the exact path to the files on your computer
2) Go to the main menu bar of LGM select ENIGMA->ENIGMA Settings and change graphics system to OpenGL3
3) Hit run, and be amazed

If you encounter an error, you likely don't have a capable graphics card support GLSL or Vertex Buffer Object's and other things provided by modern OpenGL and game engines. Or it could also be that you haven't updated ENIGMA anytime soon. At any rate this is a good time for me to remind everyone that when it comes to modern game graphics it is best for everything to be sent to the GPU and to minize draw calls as much as possible, this includes using a single model containing many basic shapes versus many objects with few basic shapes. Batching things, and minimizing interruptions to the graphics pipeline will seriously optimize your games performance, I can only do so much in the engine.
« Last Edit: December 27, 2014, 04:23:37 AM by Robert B Colton » Logged
Welcome to ENIGMO, the game engine built by fucking aliens.

Offline (Male) polygone
Reply #1 Posted on: May 24, 2013, 10:00:19 PM

Contributor
Location: England
Joined: Mar 2009
Posts: 803

View Profile
OK I updated the file:
https://www.box.com/s/00dpgpaj1wvz86s8qjqf

This is a tiny room with just 1 object. No drawing. Press up to show the fps. Or press Space to start a timer and Enter to stop it, to time a counter.
In Game Maker the fps was coming out at 7400, in ENIGMA it was only coming out at 2200. If anybody can work out why I would like to know. hmm

EDIT: Never mind I thought I commented it out before but I didn't. It's screen_redraw and screen_refresh that are responsible for all the slowdown now. It goes to 10000 without screen_redraw and 20000 without screen_refresh. Obviously GM is currently faster at this, maybe something we could look at.

EDIT2: After further debugging the two culprits have been isolated to SwapBuffers (for screen_refresh) which is obviously needed and glClear(GL_DEPTH_BUFFER_BIT); in screen_redraw which we don't need to use in 2D games so if I only enable that when in 3d mode it should put ENIGMA back on par with Game Maker (well actually a bit above it :)).
« Last Edit: May 24, 2013, 11:25:45 PM by polygone » Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Male) Goombert
Reply #2 Posted on: May 24, 2013, 11:00:44 PM

Contributor
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2988

View Profile
polygonz, Game Maker: Studio has a 16bit depth buffer, ENIGMA uses 32bit
Logged
Welcome to ENIGMO, the game engine built by fucking aliens.

Offline (Male) polygone
Reply #3 Posted on: May 25, 2013, 12:04:38 AM

Contributor
Location: England
Joined: Mar 2009
Posts: 803

View Profile
OK so I've committed the change so the depth clear only occurs in 3d mode. This should make 2D games faster. Good job I did this testing, managed to find two inefficiencies : p

In any case ENIGMA is now officially faster than Game Maker; everywhere!
Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Unknown gender) forthevin
Reply #4 Posted on: May 25, 2013, 07:47:02 AM

Contributor
Joined: Jun 2012
Posts: 171

View Profile
Josh, I have changed the fps-handling for Windows to use usleep instead of Sleep. usleep resides in the unistd.h header, and Sleep is contained in sys/time.h. I am not quite certain I understand your request regarding nanosleep, but I looked at the runtime libraries and headers for MinGW (version 3.20), and it does not contain nanosleep, only usleep and Sleep.
Logged
Offline (Male) TheZombieKiller
Reply #5 Posted on: May 25, 2013, 08:22:11 AM

Member
Location: Adelaide, Australia
Joined: May 2013
Posts: 8

View Profile Email
Is this supposed to work on Windows? I tried it from a fresh ENIGMA install and made a working build of a game, then tried this with OpenGL 3 and it didn't compile.

Errors:
Code: [Select]
.eobjs/Windows/Windows/Run/SHELLmain.o:SHELLmain.cpp:(.text+0x2cf8): undefined reference to `enigma_user::shader_program_use(int)'
.eobjs/Windows/Windows/Run/SHELLmain.o:SHELLmain.cpp:(.text+0x2d1d): undefined reference to `enigma_user::shader_program_reset()'
.eobjs/Windows/Windows/Run/SHELLmain.o:SHELLmain.cpp:(.text+0x3855): undefined reference to `enigma_user::shader_create(int)'
.eobjs/Windows/Windows/Run/SHELLmain.o:SHELLmain.cpp:(.text+0x3877): undefined reference to `enigma_user::shader_create(int)'
.eobjs/Windows/Windows/Run/SHELLmain.o:SHELLmain.cpp:(.text+0x38ac): undefined reference to `enigma_user::shader_load(int, char const*)'
.eobjs/Windows/Windows/Run/SHELLmain.o:SHELLmain.cpp:(.text+0x38cb): undefined reference to `enigma_user::shader_load(int, char const*)'
.eobjs/Windows/Windows/Run/SHELLmain.o:SHELLmain.cpp:(.text+0x38e2): undefined reference to `enigma_user::shader_compile(int)'
.eobjs/Windows/Windows/Run/SHELLmain.o:SHELLmain.cpp:(.text+0x38f9): undefined reference to `enigma_user::shader_compile(int)'
.eobjs/Windows/Windows/Run/SHELLmain.o:SHELLmain.cpp:(.text+0x38fe): undefined reference to `enigma_user::shader_program_create()'
.eobjs/Windows/Windows/Run/SHELLmain.o:SHELLmain.cpp:(.text+0x394a): undefined reference to `enigma_user::shader_program_attach(int, int)'
.eobjs/Windows/Windows/Run/SHELLmain.o:SHELLmain.cpp:(.text+0x3980): undefined reference to `enigma_user::shader_program_attach(int, int)'
.eobjs/Windows/Windows/Run/SHELLmain.o:SHELLmain.cpp:(.text+0x3997): undefined reference to `enigma_user::shader_program_link(int)'
.eobjs/Windows/Windows/Run/SHELLmain.o:SHELLmain.cpp:(.text+0x39ae): undefined reference to `enigma_user::shader_program_validate(int)'
.eobjs/Windows/Windows/Run/SHELLmain.o:SHELLmain.cpp:(.text+0x43f6): undefined reference to `enigma_user::d3d_model_create(int)'
.eobjs/Windows/Windows/Run/SHELLmain.o:SHELLmain.cpp:(.text+0x48bc): undefined reference to `enigma_user::d3d_model_block(unsigned int, double, double, double, double, double, double, int, int, bool)'
.eobjs/Windows/Windows/Run/SHELLmain.o:SHELLmain.cpp:(.text+0x5df4): undefined reference to `enigma_user::shader_program_reset()'
c:/enigma/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/ld.exe: .eobjs/Windows/Windows/Run/SHELLmain.o: bad reloc address 0x0 in section `.rdata'
c:/enigma/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[1]: *** [C:/Users/Benjamin/AppData/Local/Temp/egm4509801218762377635.tmp] Error 1
mingw32-make.exe[1]: Leaving directory `c:/ENIGMA/enigma-dev/ENIGMAsystem/SHELL'
mingw32-make.exe: *** [Game] Error 2

-TZK
« Last Edit: May 25, 2013, 08:28:48 AM by TheZombieKiller » Logged
Offline (Male) Goombert
Reply #6 Posted on: May 25, 2013, 08:31:27 AM

Contributor
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2988

View Profile
No it is not something is wrong with the makefile for Windows, me and forthevin are looking into it.  (Y)
Logged
Welcome to ENIGMO, the game engine built by fucking aliens.

Offline (Unknown gender) forthevin
Reply #7 Posted on: May 25, 2013, 10:00:21 AM

Contributor
Joined: Jun 2012
Posts: 171

View Profile
I am getting an fps around 25-28 when viewing from the start location on a laptop with an integrated graphics card from Intel. Very, very nice.

EDIT: For a temporary fix to the issue with building the file, go into ENIGMAsystem/SHELL/Makefile, and edit line 23 from:

Code: [Select]
GRAPHICS := OpenGL1

to:

Code: [Select]
GRAPHICS := OpenGL3

That should fix the issue (remember to still select OpenGL3 in the editor).
« Last Edit: May 25, 2013, 10:15:07 AM by forthevin » Logged
Offline (Male) Josh @ Dreamland
Reply #8 Posted on: May 25, 2013, 10:21:10 AM

Prince of all Goldfish
Developer
Location: Ohio, United States
Joined: Feb 2008
Posts: 2934

View Profile Email
Replace it with GRAPHICS ?= OpenGL1 for a permanent fix. YOLO

Note: I have no idea how wide support for this is. It may be limited to GNU make.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) Orpheon
Reply #9 Posted on: May 25, 2013, 10:32:23 AM
Member
Joined: Jan 2013
Posts: 3

View Profile
Can't make the fps drop under 60




Great work!
Logged
Offline (Male) Goombert
Reply #10 Posted on: May 25, 2013, 10:33:34 AM

Contributor
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2988

View Profile
I have commited this and Josh says it works on Windows and it works fine on Linux for me, so just waiting for someone to pull it.  (Y)
Logged
Welcome to ENIGMO, the game engine built by fucking aliens.

Offline (Unknown gender) forthevin
Reply #11 Posted on: May 25, 2013, 10:43:56 AM

Contributor
Joined: Jun 2012
Posts: 171

View Profile
Tested, confirmed to work and pulled.
Logged
Offline (Male) Josh @ Dreamland
Reply #12 Posted on: May 25, 2013, 12:44:04 PM

Prince of all Goldfish
Developer
Location: Ohio, United States
Joined: Feb 2008
Posts: 2934

View Profile Email
That's fine, forthevin. Anything is better than Windows' Sleep() function. Thanks.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) TheExDeus
Reply #13 Posted on: May 25, 2013, 04:13:11 PM

Developer
Joined: Apr 2008
Posts: 1886

View Profile
I also get solid 60FPS with everything turned on. But when I switch to wireframe I drop to like 6fps, although weirdly my whole PC slows down to like 6fps (even typing in firefox textboxes have about the same response time). Also, it consumes 25% (so 100% on 1 thread) on my CPU even when I have 60FPS and I am turned away.
Also:
1) Shaders still don't work for me on Windows. When I turn on the toon shader nothing changes and no errors are reported. Have you added the GL shader compiler error debug thing?
2) Anisotropic 0x is still broken and shows as if 16x (max) was enabled. I reported that before as Anisotropic at 0 is undefined in GL, and instead should be 1 (or disabled trough glEnable thing).

And the FPS is actually buggy, as the room speed is set to 30, while it caps at 60. When I set it to 999, it still caps at 60 (even if set_synchronization(false)).

edit: I also tried 100x100x100 and still 60FPS without wireframe. With wireframe like 1. I then tried 200x200x200, but the game crashed on load. I think it is because the vertex buffer size is exceeded and it doesn't die gracefully. A check like that should be implemented. Like a model returning false or something.
edit2: When I add another d3d_model_draw(blocksmodel, 1300, 0, 0, blockstexture); to effectively draw 2x200x200x200 I still get mostly 60FPS. Though it varies massively from what place I am looking from.
« Last Edit: May 25, 2013, 04:23:37 PM by TheExDeus » Logged
Offline (Male) TheZombieKiller
Reply #14 Posted on: May 25, 2013, 07:54:50 PM

Member
Location: Adelaide, Australia
Joined: May 2013
Posts: 8

View Profile Email
Thanks for that guys, both fixes worked for me. I can now use OpenGL3 in any game I want and it works fine, however, this one particular demo just crashes straight away when I run it. (and yes, I edited the shader paths)

-TZK
« Last Edit: May 25, 2013, 07:59:03 PM by TheZombieKiller » Logged
Pages: [1] 2 3
  Print