zuuz
zuuz

Reputation: 879

mipmap generation in opengl - is it hardware accelerated?

The purpose here isn't rendering, but gpgpu; it's for image blurring:

given an image, I need to blur it with a fixed given separable kernel (see e.g. Separable 2D Blur Kernel).

For GPU processing, a good popular method would be to first filter the lines, then filter the columns; and using the vertex shader and the fragment shader to do so (*)

However, if I have a fixed-sized kernel, I think I can use a fast-calculated mipmap that is close to the level I want, and then upsample it (as was suggested here) .

The question is therefore: will an opengl-created mipmap be faster than a mipmap I create myself using the method of (*)?

Put another way: is the mipmap creation optimized on the gpu itself? will it always outperform (speed-wise) user-created glsl code? or would it depend on the graphics card?

Edit: Thanks for the replies (Kahler, Jean-Simon Brochu). However, I still haven't seen any resources that explicitly say whether mipmaps generation by the gpu is faster than any user-created mipmaps, because of specific mipmap-generation-gpu-hardware...

Upvotes: 5

Views: 3870

Answers (1)

Kahler
Kahler

Reputation: 1140

OpenGL does not care how the functions are implemented.

OpenGL is a set of specifications, among them is the glGenerateMipmap.

Anyone can write a software renderer or develop a video card compliant to the specification. If it pass the tests, it's ~OpenGL certified~

That means that no function is mandatory to be performed on CPU or GPU, or anywhere, they just have to produce the OpenGL expected results.


Now for the practical side:

Nowadays, you can just assume the mipmap generation is done by the video card, because the major-vendors adopted this approach. If you really want to know, you will have to check specifically to the video card you are programing to.

As for performance, assume you can't beat the video card.

Even if you come up with some highly optimized code performed in some high-tech-full-of-things-CPU, you will have to upload the mipmaps you generated to the GPU, and this operation alone will probably take more time then letting the GPU do the work after you've uploaded the full-resolution texture.

And, if you program the mipmaping as a shader, still unlikely to beat the hard-coded (maybe even hard wired) built-in function. (and that code-alone, not counting the fact that it may schedule better, process apart, etc)


This site explains the glGenerateMipmap history better =))

Upvotes: 2

Related Questions