ENIGMA Forums

General fluff => Announcements => Topic started by: Goombert on May 24, 2013, 07:02:59 PM

Title: 1,000,000 Cubes
Post by: Goombert on May 24, 2013, 07:02:59 PM
(http://oi42.tinypic.com/x0np5f.jpg)(http://oi40.tinypic.com/301zwus.jpg)

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.
Title: Re: 1,000,000 Cubes
Post by: polygone on May 24, 2013, 10:00:19 PM
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 :)).
Title: Re: 1,000,000 Cubes
Post by: Goombert on May 24, 2013, 11:00:44 PM
polygonz, Game Maker: Studio has a 16bit depth buffer, ENIGMA uses 32bit
Title: Re: 1,000,000 Cubes
Post by: polygone on May 25, 2013, 12:04:38 AM
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!
Title: Re: 1,000,000 Cubes
Post by: forthevin on May 25, 2013, 07:47:02 AM
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.
Title: Re: 1,000,000 Cubes
Post by: TheZombieKiller on May 25, 2013, 08:22:11 AM
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
Title: Re: 1,000,000 Cubes
Post by: Goombert on May 25, 2013, 08:31:27 AM
No it is not something is wrong with the makefile for Windows, me and forthevin are looking into it.  (Y)
Title: Re: 1,000,000 Cubes
Post by: forthevin on May 25, 2013, 10:00:21 AM
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).
Title: Re: 1,000,000 Cubes
Post by: Josh @ Dreamland on May 25, 2013, 10:21:10 AM
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.
Title: Re: 1,000,000 Cubes
Post by: Orpheon on May 25, 2013, 10:32:23 AM
Can't make the fps drop under 60

(http://i.imgur.com/baP39Pz.jpg?1)


Great work!
Title: Re: 1,000,000 Cubes
Post by: Goombert on May 25, 2013, 10:33:34 AM
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)
Title: Re: 1,000,000 Cubes
Post by: forthevin on May 25, 2013, 10:43:56 AM
Tested, confirmed to work and pulled.
Title: Re: 1,000,000 Cubes
Post by: Josh @ Dreamland on May 25, 2013, 12:44:04 PM
That's fine, forthevin. Anything is better than Windows' Sleep() function. Thanks.
Title: Re: 1,000,000 Cubes
Post by: TheExDeus on May 25, 2013, 04:13:11 PM
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.
Title: Re: 1,000,000 Cubes
Post by: TheZombieKiller on May 25, 2013, 07:54:50 PM
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
Title: Re: 1,000,000 Cubes
Post by: Goombert on May 25, 2013, 08:12:00 PM
TheZombieKiller, you may not have support on your graphics card for OpenGL3, are you on Windows?
Title: Re: 1,000,000 Cubes
Post by: TheZombieKiller on May 25, 2013, 11:36:16 PM
Yes, I'm on Windows. I'm pretty sure my graphics card supports OpenGL3 since it works with all the other projects I've tried it with.
My graphics card is DEFINITELY not the best mainly because it's integrated and made by Intel, but it works pretty well despite that fact, surprisingly.

-- System --
Manufacturer: eMachines
Model: eMachines E525
Rating: 3.3
Processor: Intel(R) Celeron(R) CPU 900 @ 2.20 GHz 2.19 GHz
RAM: 2.00 GB
System Type: 64-bit Operating System
Graphics Card: Mobile Intel(R) 4 Series Express Chipset Family

-- Ratings --
Processor: 4.4
Graphics: 3.4
Gaming Graphics: 3.3
Primary Hard Disk: 5.9

-TZK
Title: Re: 1,000,000 Cubes
Post by: Goombert on May 25, 2013, 11:59:49 PM
Well you see Intel has a history of bad OpenGL support. It would be better if you could run the Glu test found here...
http://glew.sourceforge.net/

Then I would know exactly what your graphics card supports and what it does not as far as OpenGL. And that has nothing to do with you being able to run other projects, they all use OpenGL1 features, OpenGL3 does things differently and offloads most of everything to the GPU and graphics card, and all the GLSL stuff and what not.
Title: Re: 1,000,000 Cubes
Post by: TheZombieKiller on May 26, 2013, 12:30:42 AM
Well, crap, it seems that my graphics card doesn't support GL3 then.

-TZK
Title: Re: 1,000,000 Cubes
Post by: Goombert on May 26, 2013, 12:40:35 AM
It is ok do not feel bad, were not going to leave ya in the dark.were just leaving era of when computers did not have all this hardware acelleration, now a days they are putting them in your toasters, and %25 of Steam users still don't have the capability either, so ENIGMA intends to remain backwards compatibility with older OpenGL versions until it is no longer an issue. But anyway, you most likely wouldn't even be able to run GM:S in that case, it has much higher system requirements without backwards compatibility.  (Y)
Title: Re: 1,000,000 Cubes
Post by: TheZombieKiller on May 26, 2013, 12:47:57 AM
Surprisingly enough, GM:S runs pretty well on this machine, but nowhere near as fast as ENIGMA of course.

-TZK
Title: Re: 1,000,000 Cubes
Post by: Goombert on May 26, 2013, 12:54:15 AM
Ahhh you must have good DirectX then, a lot like my VirtualMachine. :P
Title: Re: 1,000,000 Cubes
Post by: forthevin on May 26, 2013, 03:20:22 AM
Josh: I looked into the conditional variable assignment operator, or ?=, and it is described in the documentation of both GNU make, pmake and makepp, so it is at least not limited to GNU make. I don't know how widely supported it is beyond that, however.

TheExDeus: In the start of obj_gamestate, room_speed is assigned 1000, so it makes sense that the fps goes beyond the 30 room_speed that the room starts with. The synchronization is still an issue, however.
Title: Re: 1,000,000 Cubes
Post by: Josh @ Dreamland on May 26, 2013, 08:45:40 AM
Awesome, forthevin; that makes me feel better. My concern was mostly with Microsoft makefiles, about which I know nothing but assume that they are similar, but just different enough to give us hassle. But as long as they're the minority, I don't feel bad, because apparently the behavior of := wrt parameters passed via command line is even less predictable, so I'm done caring.
Title: Re: 1,000,000 Cubes
Post by: zesterer on May 27, 2013, 05:07:20 AM
Bloody hell... Am I right in saying that this is 1,000,000 x 6 sides x 2 polys per side = 12 million polygons? Drawn at 60 fps?

*Jaw drop*
Title: Re: 1,000,000 Cubes
Post by: TheExDeus on May 27, 2013, 06:25:36 AM
More precisely it's 12 million triangles. Although I get 60fps even with culling turned off, so then its draws effectively 24million triangles. The problems though is wireframe. I think something is terribly wrong with that drawing mode as previously it was no problem to use it, but now it decimates my FPS even when relatively few objects are drawn.
Title: Re: 1,000,000 Cubes
Post by: Goombert on May 27, 2013, 06:47:35 AM
I was the one who implemented the rendering modes Deus, I have not touched them either since I originally added them.
Title: Re: 1,000,000 Cubes
Post by: TheExDeus on May 27, 2013, 12:26:40 PM
After reimplementing set_syncronization() function (so I can turn off vsync) I get:
https://dl.dropboxusercontent.com/u/21117924/Perf/Perf.png
while with wireframe I get this:
https://dl.dropboxusercontent.com/u/21117924/Perf/Perf_wire.png
Title: Re: 1,000,000 Cubes
Post by: polygone on May 27, 2013, 12:31:56 PM
663fps for a million cubes. There you go Robert that's a better tagline ^
Title: Re: 1,000,000 Cubes
Post by: TheExDeus on May 27, 2013, 12:46:53 PM
That was not a million. The default values for the Roberts example are 100x100x20, so that was 200 000. This is a million:
https://dl.dropboxusercontent.com/u/21117924/Perf/Perf_wire_million.png

edit: We do need to profile it though. It is clearly CPU bound, as the demo consumes 100% of the allocated CPU (25% on my quad core).
Title: Re: 1,000,000 Cubes
Post by: polygone on May 27, 2013, 01:27:42 PM
That screenshot doesn't look good with those streaks in it. But still, 147fps is a lot better :)
Title: Re: 1,000,000 Cubes
Post by: TheExDeus on May 27, 2013, 01:32:45 PM
Well those are a lot of boxes. And AA would help. I still we should be able to get a lot more FPS as well, though over 500FPS I think there is a problem with timing. I guess about 100-200FPS should be the target for a complex scene like this.
Title: Re: 1,000,000 Cubes
Post by: polygone on May 27, 2013, 01:36:58 PM
Isn't that blue line through the middle happening because your camera view is aligned straight with it. So you're actually seeing through the groups of boxes?
Title: Re: 1,000,000 Cubes
Post by: TheExDeus on May 27, 2013, 02:06:36 PM
Yes it is.
Title: Re: 1,000,000 Cubes
Post by: Goombert on May 27, 2013, 08:05:57 PM
Damn Harri, nice graphics card  :D And yes when you guys are working on the frame swapping or whatever I think we should take the oppurtunity to implement MSAA and SSAA.
Title: Re: 1,000,000 Cubes
Post by: Goombert on June 02, 2013, 12:25:56 PM
Alright what the FUCK you guys? Polygonz did you delete me post about 1,000,000 cubes? What the hell who deleted it? That is more important for announcements than this stupid crap, they should have been one topic anyway. Josh, tell whoever is messing with my posts to knock it off.