Educate me: fixed function vs programmable pipeple in OpenGL

Not about OpenMW? Just about Morrowind in general? Have some random babble? Kindly direct it here.
User avatar
raevol
Posts: 3093
Joined: 07 Aug 2011, 01:12
Location: Caldera

Educate me: fixed function vs programmable pipeple in OpenGL

Post by raevol »

So I'm making this a new thread instead of burdening the active discussion in the Very Low FPS thread, but I've seen "fixed function" thrown around a few times and I want to learn some things.

I started teaching myself OpenGL a bit ago, and I'm barely a few hours and a few dozen lines into learning it (I rendered a triangle, that's it) so I'm very ignorant about everything here...

BUT

going off of the tutorial I am reading, it's trying to indoctrinate me into thinking that fixed function is a waste of time and programmable is the only worthwhile investment of my time. So now my questions:

Is this true?

Should I bother with fixed function?

What do we use with OpenMW?

What should we be using with OpenMW? And why?

Should we be having any discussions about things we should or should not be doing differently?

And apologies in advance if my ignorance of this subject has produced a topic that is a complete waste of time. But, fingers crossed or whatever.
User avatar
wareya
Posts: 338
Joined: 09 May 2015, 13:07

Re: Educate me: fixed function vs programmable pipeple in OpenGL

Post by wareya »

tl;dr: depth divide, the default texture sampler, non-geometry-shader tessellation, etc. are fixed function. "fixed function" is the parts of the pipeline that you don't program. however, in GL 1 and 2, pretty much the entire pipeline was fixed function, so it's called the fixed function pipeline.

Your tutorial is trying to tell you to use GL 3.3 with vertex buffers and vertex/fragment shaders instead of writing glVertex3f over and over again. And it's right.
User avatar
AnyOldName3
Posts: 2667
Joined: 26 Nov 2015, 03:25

Re: Educate me: fixed function vs programmable pipeple in OpenGL

Post by AnyOldName3 »

Is this true?
The only time you'd ever care about anything fixed-function is when you're working on an existing application that's had fixed-function stuff in it all along. If you're using fixed function stuff for anything in a new application, you're an idiot.
Should I bother with fixed function?
Only if you're going to be working on applications that already use it.
What do we use with OpenMW?
Most things OpenMW can do can be done entirely with the fixed-function pipeline, and unless you enable an effect that requires shaders, the FFP is what gets used. However, shadows, normal mapping and other fancy effects don't work with the FFP, so we use shaders, too.
What should we be using with OpenMW? And why?
The main benefits of the FFP are that:
  • It's supported on some pretty old hardware that doesn't support shaders. There isn't actually that much of that kind of hardware that works with operating systems we support, though.
  • We know that it's doing the same thing as vanilla Morrowind as that used the FFP for nearly everything (although via Direct3D instead of OpenGL).
  • OSG predates shaders, so lots of aspects of how it works are written with an FFP-first attitude. Its system to combine statesets works very, very well with the FFP, but can be a little janky with shaders. You can attach a whole shader program to a stateset, and you can attach uniforms (data that gets used by the shader and is the same for every vertex and pixel in a draw call) and as of OSG 3.4, you can attach preprocessor definitions, but this is messier than just saying you want to turn off fog for a subgraph. Also, things like OSG's light system assume you're either using the FFP or an old version of shaders that has access to FFP state.
Shaders are much more flexible, powerful, and likely to do what they're told on modern hardware. If the option to not use them were a new thing, no one would take it.

If we'd have started the OSG port after OSG 3.4 released, we'd probably be using its shader composition feature and could have more easily achieved certain things, but that's kind of a moot point now. Lots of things that are difficult are difficult because we don't want to unnecessarily break fixed-function compatibility. Some things that are difficult are difficult because we want to continue supporting older OpenGL versions, too.
Should we be having any discussions about things we should or should not be doing differently?
We probably should, but only up to a certain point. If all the people who know about graphics programming are always busy rehashing the same debate, nothing will ever get done.
Chris
Posts: 1625
Joined: 04 Sep 2011, 08:33

Re: Educate me: fixed function vs programmable pipeple in OpenGL

Post by Chris »

raevol wrote: 01 May 2019, 04:46 going off of the tutorial I am reading, it's trying to indoctrinate me into thinking that fixed function is a waste of time and programmable is the only worthwhile investment of my time. So now my questions:

Is this true?
More or less, yes. Fixed-function was already on its way out a decade ago, and drivers implement the fixed-function pipeline with shaders.
Should I bother with fixed function?
Not if you're looking to get into serious or semi-serious 3D work. Aside from the fixed-function/programmable debate itself, GL3 and newer adds a number of features to more efficiently use hardware, and using GL3 with the fixed-function pipeline is a sketchy proposition (the FFP was deprecated with GL3, so you can only get it with a compatibility profile, but using a compatibility profile may lock you out of newer features, so its really one or the other).
What do we use with OpenMW?

What should we be using with OpenMW? And why?
Currently OpenMW uses fixed-function, though can switch to use programmable/shaders as needed. However, I would say this is more than backwards; rather than using programmable/shaders as a fallback for when fixed-function doesn't work for some feature, we should drop fixed-function and use only a programmable path, IMO.

At the time, I suppose the thinking was since vanilla used fixed-function, us also using it helped ensure similar results, and it is quicker to get stuff rendering with fixed-function. However, OpenMW is aiming to be a more modern engine for more modern systems, and no modern or even semi-modern system relies on fixed-function, and we're already hitting into stuff that can't work with fixed-function (at least, not without a much larger time investment). Having to support both a programmable shader path and a fixed-function paths increases maintenance cost, especially as we go into the future and the two paths diverge. Being that no modern system relies on fixed-function, supporting it along side a programmable path is going to take up time.
Should we be having any discussions about things we should or should not be doing differently?
It's always good to have discussions about how things could or should be done. The computing landscape is always changing, so the things it makes sense to do now may no longer make sense in 5 to 10 years. As long as it doesn't get in the way of actually getting things done, we should always be open to discussion.
User avatar
raevol
Posts: 3093
Joined: 07 Aug 2011, 01:12
Location: Caldera

Re: Educate me: fixed function vs programmable pipeple in OpenGL

Post by raevol »

Thanks everybody, this is very informative.

For myself, I'm happy I am learning the shader pipeline after reading what you are saying. I'll keep going forward with that.

For OpenMW, please correct me where I am wrong with this statement, but it seems like if someone with the skills, time, and motivation to switch us off of OSG, or at least off of all of the fixed function parts of OSG (the extent of which I am not certain) that that work would benefit us a lot. But it would be a ton of work.
User avatar
AnyOldName3
Posts: 2667
Joined: 26 Nov 2015, 03:25

Re: Educate me: fixed function vs programmable pipeple in OpenGL

Post by AnyOldName3 »

If we go shader-only, that'll make some things much easier going forward, but we'll stop supporting a chunk of hardware that people still use. It'll also make some things harder as OSG won't magically do them for us any more.
User avatar
Stomy
Posts: 47
Joined: 11 Dec 2018, 02:55
Location: Fhloston Paradise!
Contact:

Re: Educate me: fixed function vs programmable pipeple in OpenGL

Post by Stomy »

Yeah, my intention if I do end up making the dedicated system would be to make shaders the default behavior and fixed-function a legacy backup option rather than the way it is now. The idea would be that people could still use the old hardware but any further innovations would be on the shader-based approach, and the system would be optimized to assume it was in use.
User avatar
raevol
Posts: 3093
Joined: 07 Aug 2011, 01:12
Location: Caldera

Re: Educate me: fixed function vs programmable pipeple in OpenGL

Post by raevol »

I was going to look at the Steam hardware survey to see how common old OpenGL support is, but the survey is down. :(
User avatar
Stomy
Posts: 47
Joined: 11 Dec 2018, 02:55
Location: Fhloston Paradise!
Contact:

Re: Educate me: fixed function vs programmable pipeple in OpenGL

Post by Stomy »

There's also the OpenGL report data from 0 A.D., might even be more representative of our player base being another open-source game.
https://feedback.wildfiregames.com/report/opengl/
Chris
Posts: 1625
Joined: 04 Sep 2011, 08:33

Re: Educate me: fixed function vs programmable pipeple in OpenGL

Post by Chris »

AnyOldName3 wrote: 01 May 2019, 23:33 If we go shader-only, that'll make some things much easier going forward, but we'll stop supporting a chunk of hardware that people still use.
I'm curious how many people actually use such hardware. The GeForce 8 series of cards was released in late 2006, and supported a fully programmable pipeline (GL3/D3D10). 12 and a half years later, that line of cards is considered ancient. I'd wonder if a system with that kind of card even has a good enough CPU or enough RAM to run OpenMW properly.

FWIW, GZDoom ran some surveys last year when they were deciding what needed supporting based on what people were using. Their last survey, from August last year, had the number of people with GL2-only cards at 2.5% (down from 6% four months prior). That was enough for them to essentially drop it and focus solely on GL3/4 (and recently, Vulkan), though even if they hadn't it would definitely be less than 2.5% now.

Considering Doom targets an even older demographic than Morrowind, I wouldn't be surprised if users with GL2-only devices is even less for us. However, I wouldn't use this alone as reason to drop FFP support. I would, though, use this as reason that focus should be on GL3+ devices, with FFP effectively being on life support (let it stay if necessary, and fix any glaring issue it may have, but don't have it as the default and don't worry about if it has every feature it potentially could) with potential to drop it if it becomes too much of a hassle.

* The survey was included in the engine and sent anonymous statistics (with user consent) to a server that compiled the stats, and took some minor steps to ignore attempts at artificial stat inflation (e.g. someone with a low- or high-end system sending a bunch of reports, to make it seem like there's more of that kind of system than there actually are). Hardly a flawless solution, but it was more than mere forum polls.
Post Reply