Compute Shaders before OpenGL 4

Hi everyone,

I was wandering if parallel computing using floating point on the GPU was even a thing (OpenGL) before compute shaders.

For compatibility reasons I can’t use the latest OpenGL features so I’m currently performing parallel computing using vertex and fragment shaders and reading the results of the algorithms as pixel values.

Are there ways to have something similar to a compute shader in older versions of OpenGL or maybe better tricks than the one I’m using right now?

There was/is also transform feedback, which would let you perform the computation in the vertex shader.

1 Like

Thanks @Midnightas,

The problem is that a some users still rely on outdated hardware and drivers (even using VBOs could be a problem for some of them…)

I’m probably going to stay with OpenGL 2.x for now, and it seems that transform feedback requires newer versions.

VBOs were introduced in OpenGL 1.5 - way back in 2003 - History of OpenGL - OpenGL Wiki

Do you actually want to support hardware that old?

1 Like

Yes, absolutely! 15-20 years ago, well before we had compute shaders and GPU compute languages.

The acronym to websearch for is GPGPU - General Purpose GPU Computing.

At the time, there was a clustering of like minds on this in various places on the net including gpgpu.org. Nowadays you don’t have to bend over backwards so hard to use the GPU for general purpose computing. But you still can if you need to – there’s nothing that precludes it. It fact it’s easier nowadays, since the capabilities of GPUs and GPU rendering APIs like OpenGL and Vulkan have been expanded significantly.

1 Like

I don’t know of any implementation that supports shaders and not buffer objects. I mean, you could cobble together some kind of computations with texture environment settings, but you’re talking about fixed-function stuff here.

Also, such implementations may well be extremely buggy and will never get patches to fix them.

In theory I suppose they can exist - they would be GL 1.4 (or lower) implementations that support GL_ARB_shader_objects (or even GL_ARB_vertex_program and GL_ARB_fragment_program) but not GL_ARB_vertex_buffer_object. It would be very obscure, short-lived hardware, however.

Vertex buffer objects are core OpenGL in version 1.5 onwards, so every GL 1.5 or higher implementation supports VBOs - including your GL 2.x target.

Just to give some context here: people do on occasion use support for older hardware as a rationale for retaining downlevel codepaths, and it invariably turns out that they’re unaware that the downlevel codepaths are actually completely unnecessary, and that the older hardware they want to still support actually does support shaders, buffers, etc.

This is probably a messaging problem. Because core modern GL forces you to use buffer objects, the impression seems to be that buffer objects are a core modern GL feature, for example. The thing is, they’re actually not - they’re actually an old old old feature that even pre-dates shaders.

2 Likes

The other common approach to simulating compute shaders is render-to-texture (i.e. framebuffer objects).

Both of these have the limitation that they only support “gather”-style calculations (where each parallel invocation has a pre-determined output index but input indices can be calculated during the invocation), not “scatter” (where an invocation can compute the output index). For scatter, you realistically need Image Load Store.

1 Like