-1

For my Application I need a renderer. The renderer uses the OpenGL 3.3 core profile as a basic. In newer OpenGL versions, there are some neat features, which are also available via extensions. If available I want to use newer features, based on the newest OpenGL version. Since it's a mess to test for available versions and adjust the loader, I decided to remain at core 3.3 and use extensions where available (as this are extensions for, right?).

Are Extensions as fast as the same funcionality in newer OpenGL versions?

Let's take the GL_ARB_direct_state_access-extension. It's available in core since 4.5 via Direct State Access. Is the latter faster than the former? I.e. are the functions implemented in newer versions faster than extensions? Or do driver link to the same function anyway?

E: This is not a question about software design rather than about how extensions are handled (mostly?) and about performance.

Tim Diekmann
  • 7,755
  • 11
  • 41
  • 69
  • I would choose a version and stick with it. I wouldn't use "fancy" extensions either. If you need facilities provided by a later version, use the later version and make that your baseline. It'll give you much more maintainable code in the long run. I have found direct state access makes it far, far easier to wrap GL objects as C++ objects, with less state change. Almost certainly faster too (fewer calls). – Robinson Feb 11 '18 at 00:11
  • Thanks for the reply, but this isn't a question about maintainable code. – Tim Diekmann Feb 11 '18 at 00:41
  • @Robinson: "*I wouldn't use "fancy" extensions either.*" What is a "fancy" extension? While I generally agree with your sentiment for *specific* extensions (it makes absolutely no sense to write code that has separate codepaths for DSA and non-DSA implementations), there are many reasons why one might conditionally use certain features. *Hardware* features, not API convenience features. – Nicol Bolas Feb 11 '18 at 02:06
  • 1
    `GL_ARB_direct_state_access` is the same extension whether the driver supports 4.5 core or not, so it should be the same implementation, but it's up to the driver. – pleluron Feb 12 '18 at 00:12

2 Answers2

1

Actually, the OpenGL API spec XML description has the nice property of alias. A GL function aliasing another one is basically both syntactically and semantically identical to the function it is aliasing - and this feature is used a lot when extension function become promoted to core functionality and have their names changed.

There are GL Loaders out there which actually use that information. Two examples I know of are:

  • libepoxy
  • glad2 (glad2 is current in-development branch of the glad loader generator - but I'm using it since 2 years without any issue). You'll have to explicitely enable the aliasing feature. There is also a web service which lets you generate the needed files (note the "aliasing" button on the bottom). Also have a look at the GLAD documentation.

With such a loader, you do not have to care about whether a particular function comes from an extension or from the GL core functionality, you can just use them if they are available somehow.

Also note that with newer extensions, the OpenGL ARB more often is creating ARB extensions without the ARB suffix on the function and enum names, which means that it is describing the exact same entities in any case. This is basically done for extensions which were created after the features were incorporated into the core standard. They just create an extension for it so that a vendor, who might not be able to fulfill some other requirement of the new standard version, is still available to provide the isoltated feature.

One of the first examples of this was the GL_ARB_sync extension, which itself relates to this fact in issue #13:

13) Why don't the entry points/enums have ARB appended?

This functionality is going directly into the OpenGL 3.2 core and also being defined as an extension for older > platforms at the same time, so it does not use ARB suffixes, like other such new features going directly into the GL core.

You wrote :

Let's take the GL_ARB_direct_state_access-extension. It's available in core since 4.5 via Direct State Access. Is the latter faster than the former? I.e. are the functions implemented in newer versions faster than extensions? Or do driver link to the same function anyway?

GL_ARB_direct_state_access falls into the same category as GL_ARB_sync. The GL functions are identified by name, and two entities having the same name means that they are referencing the very same thing. (You can't export two different functions with the same name in a library, and *glGetProcAddress also takes only the name string as input, so it can't decide which version you wanted if there were more than one).

However, it will still depend on your GL loading meachanism how this situation is dealt with, because it might not attempt on loading functions which are not implied by the GL version you got. glad2 for example will just work if you choose it to generate a >= 4.5 loader or to support the GL_ARB_direct_state_access extension.

Since it's a mess to test for available versions and adjust the loader, [...]

Well. That will greatly depend on the loader you are using. As I have shown, there are already options which will basically jsut work, not only in the case of absolute identical function names, but also with aliased functions.

derhass
  • 43,833
  • 2
  • 57
  • 78
0

Are Extensions as fast as the same funcionality in newer OpenGL versions

An extension is sort of a preview of the feature. Many (most?) extensions are included in the standard when a new version arrives, so performance will be equal.

You should look at your target platform(s). When I run OpenGL Extensions Viewer it tells that my HD3000 supports all features up to 3.1, 70% of 3.2 / 3.3 and 21% of 4.0. So you can check in advance if the feature you need is implemented on your target platform(s) with the hardware and drivers you want to use. Most recent hardware will support 4.4 / 4.5 because it's been around for years. It's up to you how much you value backwards compatibility.

When I look at Intel graphics since Skylake and beyond it supports 4.4, Skylake is around since 08/2015. All AMD/NVidia hardware will also support 4.4 / 4.5. Note that the support level may very between OS and driver versions.