Direct3D9 vs OpenGL 2.0 - discrepancy in speed

Started by
14 comments, last by maxest 12 years, 6 months ago

Could it be that GLSL is more effective than pure "old-school" ARB ASM shaders?


Hand-coded ASM shaders should be more efficient as you get more direct control over what instructions get executed, and in which order they happen, but you really need to know what you're doing and know what GPUs like and don't like to get the best out of them. Could be that the Cg to ASM converter was doing a bad job, could be that your GLSL compiler is actually really really good.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Advertisement
You're still measuring performance in FPS, and still haven't determined weather you're CPU bound or GPU bound.
Until then, these tests are meaningless -- if your 40ms frame times are bottlenecked by GPU time, then the API-side draw call cost isn't even being measured...
On Intel integrated chips like the HD Graphics the difference is ridiculous - although the rendering is correct, OpenGL gets single-digit framerates where Direct3D9 would get something like 40-50.
That is an indication that you're using some feature that is not supported in hardware, which forces GL to run in software emulated mode (e.g. performing an array-lookup in a pixel shader on a card with no pixel-shader address registers may cause that pixel shader to run on the CPU!).
Intel seems to have a reputation for not giving a crap about writing OpenGL drivers that don't actually suck, so it can be a good idea to implement a Direct3D code path for those poor unfortunates with Intel integrated.
Since your test case includes a lot of overdraw, did you manually change the depth-test settings?
OpenGL defaults to GL_LESS while DirectX defaults to D3DCMP_LESSEQUAL.
A fair test will require you to manually change one or the other.

As for my experience, I wonder why you expected OpenGL to be faster than DirectX.
My engine from a tiny shell to what it is now has always shown OpenGL to be slower than DirectX, and the more I add to it the farther OpenGL falls behind. Currently, the OpenGL side is literally half the speed of the DirectX side, thanks to a lot of optimizations that work for DirectX but not OpenGL, such as padding vertex buffers to 32 bytes. That helped DirectX tremendously whereas doing so for OpenGL just made it slower (extra bus transfer).

But as mentioned that usually falls back on the drivers the vendors (didn’t) care(d) to implement.
I have tested on a lot of machines though, and the best my OpenGL side can do is about 80% of the DirectX side.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid


That is an indication that you're using some feature that is not supported in hardware, which forces GL to run in software emulated mode (e.g. performing an array-lookup in a pixel shader on a card with no pixel-shader address registers may cause that pixel shader to run on the CPU!).


Now that you said that it inspired me to pinpoint exactly when the slowdown happens in my engine, and turns out it's when there are any hardware skinned characters visible. Thank you! Now to just find the solution :)

EDIT: The real culprit appears to be vertex count, not skinning per se. I'm led to believe that for some reason the driver decides to execute the vertex shader in software. Fragment shaders seem to execute at acceptable speed, though.
@YogurtEmperor: the test for both of them is less-equal.
I didn't expect OGL to be faster, sorry for my misexpression. First off I hoped them to be more or less equally fast. But when I saw D3D9 to be faster in some situations, I at least wanted to find some situations where OGL is faster, to see some compensation. But as far as I see you guys are experiencing similar problems. It's astonishing how important is the driver in this. Silicon is the same but the perf. can differ really vastly. Yet still, there's Unigine Heaven demo which yields very close perf. for both renderers :). I think I need to recheck that one.

EDIT: I just rechecked the Heaven's demo. On my GeForce 540M with relatively semi-high settings I get:
d3d9:

FPS: 18.6
Scores: 468
Min FPS: 11.7
Max FPS: 35.1

ogl:

FPS: 17.6
Scores: 444
Min FPS: 11.1
Max FPS: 30.5

So on average the performance is pretty much the same.

This topic is closed to new replies.

Advertisement