OpenGL v DirectX

BlitzMax Forums/BlitzMax Programming/OpenGL v DirectX

Diablo(Posted 2005) [#1]
Which one is faster for you, run this code and tell me your FPS for each of the Tests:


The test are as follows:
Test1 - Tests shape drawing
Test2 - Tests image drawing


my results are:
TEST 1:
DirectX = 41
OpenGL = 102

TEST 2:
DirectX = 41
OpenGL = 62


EDIT: I should say I have a really crapy Graphics Card (sapphire ATI 9600)

I ask because I want to know which one is fastest on a rage of different computers.

BTW if you find anything in the code that looks like it would make it an unfair test, can you please post the fixed code. Thx


Stuart Morgan(Posted 2005) [#2]

Debug

Test 1
DX = 49
GL = 211

Test 2
DX = 44
GL = 123

Non Debug

Test 1
DX = 56
GL = 408

Test 2
DX = 55
GL = 298


Win2K SP4, 2600+, Radeon 9800 Pro, 512 RAM


Muttley(Posted 2005) [#3]
My results. First in debug mode:

TEST 1:
DirectX = 33
OpenGL = 151

TEST 2:
DirectX = 33
OpenGL = 118

Now, not in debug:

TEST 1:
DirectX = 36
OpenGL = 366

TEST 2:
DirectX = 39
OpenGL = 275

This is with a P4 2.6GHz, 1GB RAM, NVidia GeForce 6800 (Detonator 77.72 drivers)

Muttley


Gabriel(Posted 2005) [#4]
Test 1
DX = 50
GL = 500

Test 2
DX = 50
GL = 380


tonyg(Posted 2005) [#5]
Test 1
DX = 43
GL = 166

Test 2
DX = 37
GL = 94

WinXP SP2, 2700+, 9800Pro, 1Gig RAM


Mark Tiffany(Posted 2005) [#6]
There's summat up with these tests - this can't be right!
Test 1
DX = 52
GL = 612

Test 2
DX = 52
GL = 420

(running on my winxp box)


Mark Tiffany(Posted 2005) [#7]
woot! I trounced both muttley's 6800 and tonyg's 9800Pro. :D


Diablo(Posted 2005) [#8]
There's summat up with these tests - this can't be right!


mabey its my coding, I wrote the test while half asleep, but i noticed these huge differences while develop my current project so I thought I'd try and create a test - so far it seems OpenGL is faaaaaaaar faster then DX, which is the reult I got in my project.

if you find somthing wrong with the code please post an update.


WendellM(Posted 2005) [#9]
On Athlon XP 3000+, Radeon 9600 Pro, Win XP Pro SP2, BlitzMax 1.12, Non-Debug:

Test 1
DX = 54
GL = 496

Test 2
DX = 52
GL = 363


Robert Cummings(Posted 2005) [#10]
Perhaps you're forgetting flip false?

I tried it with flip 0 (necessary in 1.12) and I agree, even on the ati card, ogl is always twice as fast or more.

That is very strange.

I'm getting 4x the speed on average with OpenGL... what is max doing that is so slow with DX?


WendellM(Posted 2005) [#11]
Curious, I tried a few things, like using Strict with loop locals, using a function instead of inline code, etc. and couldn't get a significant change.

Changing from DrawRect to DrawOval in Test 1 makes a big change, though. I went from DX = 54 / GL = 496 to:

Test 1
DX = 20
GL = 40

So it looks like GL's DrawRect might be much faster than DX's, while its DrawOval is less so.

Using ovals makes no difference with Test2 since it's DrawImage that counts. In Blitz3D, there's "DrawBlock" which is faster than its DrawImage due to no masking, but turning off masking here didn't help. I tried using DrawImageRect but there was no significant change (both DX and GL were a tad slower).


Duckstab[o](Posted 2005) [#12]
Yep Just did a test with 16*16 bitmaps

First Test:
Graphics set to 1280*1024*32*0
Drawing 5120 bitmaps to screen
Then Flip False

DirectX Result = 67Fps
Opengl Result=200Fps

SecondTest:
Graphics set to 1280*1024*32*0
Setblend(ALPHABLEND)
Drawing 5120 bitmaps to screen
SetBlend(SHADEBLEND)
Drawing 5120 bitmaps to screen
Then Flip False

DirectX Result = 34Fps
Opengl Result=100Fps


And Results using Diablos Test

Test 1
Directx =56
Opengl=600-602

Test 2
Directx =53
Opengl=405-408


RGR(Posted 2005) [#13]
Test 1
65
705

Test 2
66
503

Exact same results 1024x768 and 1600x1200
.


Dubious Drewski(Posted 2005) [#14]
test1
45
410

test2
40
361

WinXp, Geforce 6800 GT

What's going on here? Everyone's Dx seems to be
consistently 5-10x slower than OGL. Is that because
Mark favours OGL/Mac and therefore has
optimized/understood it better when writing?


Hotcakes(Posted 2005) [#15]
It's probably just an easier API to understand in the first place. But those results are disturbing.


Leiden(Posted 2005) [#16]
Here's my results:

Test 1 DX: 59
Test 1 GL: 569
Test 2 DX: 58
Test 2 DX: 411

Looks like OpenGL kicks ass! But as Toby says the results are pretty scary. Anyone tested on Max 1.10?


Picklesworth(Posted 2005) [#17]
this can't be right!
The reason is, quite simply, because OpenGL is faster (and thus better) than DirectX.

A difference as extreme as shown here points to a problem somewhere with nothing to do with DX or OGL, though.


Dubious Drewski(Posted 2005) [#18]
I tested on max 110


Leiden(Posted 2005) [#19]
The DirectX results seem to be withing 10 fps of each other on different machine specs while the OpenGL results have a huge variation. Perhaps the DX frame rate is being limited/manipulated somehow or its the result of using an outdated API?


Dreamora(Posted 2005) [#20]
I get about the same results.

But I didn't expect anything else to tell the truth, because DX is used in a "unmeant" way within Max2D (making it work like OpenGL which BM Max2D commands focus on while DX is meant and optimized to work quite different) ...

would be like programming procedural with a mainloop within a event based environment ...

You should, at least at the moment, only use DX as fall back ...
Thats the price of the procedural "1 look & feel" implementation of Max2D


Diablo(Posted 2005) [#21]
I tried it with flip 0 (necessary in 1.12) and I agree, even on the ati card, ogl is always twice as fast or more.

Hu, I didn't even now about this - [EDIT that is flip 0 :P].

Looks like your right Dreamora, openGL is the way to go in blitzMax, thx everyone for testing :)

..EDIT: I just got some screen shots together of my current project and its kinda worring considering the above:

This first on is DirectX drawing a bunch of images (including the HUD):

FPS = 157

This second one is DirectX trying to draw rects(minimap) and images:

FPS = 30

Now openGL rendering images:

FPS = 134 - [ THATS SLOWER THEN DIRECTX ? ]

And openGL rendering rects:

FPS = 70 [FASTER THEN DIRECTX]

This is the first reason why I created these test :P

This whole thing is just freeking me out.


xlsior(Posted 2005) [#22]
DX: 52
OGL: 454

DX: 49
OGL: 300


Robert Cummings(Posted 2005) [#23]
I think it might have something to do with how DX is being set up or something. I believe when it's fixed (this should be considered a minor bug) it should be within 50% of GL speed.

Perhaps someone would like to dig deeply in the modules to see where the problem lies. I'm just not experienced enough. Or post in bug reports. I gave it a look but it doesn't seem apparent to me.

edit: confirmed the speed gap in own game.


Duckstab[o](Posted 2005) [#24]
Try knocking up a dx.exe gl.exe for us to test and see if it your graphics card that causes the slower opengl in your screenies


Mark Tiffany(Posted 2005) [#25]
Is it as simple as the DX driver being forced to wait for a vblank somewhere? Not convinced, as the numbers posted for DX (and certainly for me) aren't entirely consistent with normal refresh rates...


Diablo(Posted 2005) [#26]
@Duckstab
OK, I have just uploaded a zip containg a two binarys, DX.exe & GL.exe. Get them here (while you still can) GLvDX_EngineTest.zip

Click the 'N' icon to change the view to minimap(DrawRect) & the target one to change to the ISO view(DrawImage).


Duckstab[o](Posted 2005) [#27]
Just tested the Exes

DirectX Results
Drawimage 322 fps
DrawRect 35 Fps

Opengl Results
Drawimage 632 Fps "note This Had Glitches what bit is it set to 16 or 32
DrawRect 245 Fps


Diablo(Posted 2005) [#28]
Its set to 16 bit but if ur getting problems (and if anyone else is) I will put this upto 32bit.


TartanTangerine (was Indiepath)(Posted 2005) [#29]
Does OpenGl utilise hardware T&L if it's present? Does OGL automatically cache vertices in VidMem? Does OGL automatically use shared vertices and buffers?

If you implement Hardware T&L for DirectX and use my VertexBuffer code then there is little difference between the speeds. Granted it's not standard BMax stuff and it's not automatic but it helps.


Robert Cummings(Posted 2005) [#30]
I do not think OpenGL does T&L. I think there is an underlying major problem with DX at the moment.


Dreamora(Posted 2005) [#31]
None of this things is done in VRAM in the OpenGL 1.2 implementation of BM.
The main difference is that BM D3D gives DX the control over where to put the texture while OpenGL forces the VRAM for it ...

But as said, DX works differently ... switching states xy times per frame or recreating the same stupid quad over and over again instead of repositioning it is not really what D3D was made for ...
It does not have its native model format for fun ;-)


Robert Cummings(Posted 2005) [#32]
I think that it will be as fast as OGL, or within 10% of the speed when it is fixed.


Leiden(Posted 2005) [#33]
It should be faster than OpenGL on Windows Machines. Guarenteed its done right.


Hotcakes(Posted 2005) [#34]
No, OGL has always run faster on my machine than DX. But DX should not be so far behind as this.


Chroma(Posted 2005) [#35]
Test 1:
DX=70
OpenGL=622

Test 2:
DX=64
OpenGL=420