4

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...

Community
  • 1
  • 1
zuuz
  • 859
  • 1
  • 12
  • 23
  • I don't have a complete answer but a custom GLSL shader WILL be massively parallelized. A good card can process 1000 fragments at the same time. But there is nothing like a good performance test. – Jean-Simon Brochu Apr 11 '14 at 16:04
  • That Rastergrid article you mentioned is so good! Luck to every OpenGL learner that stumbles across it! – Kahler Apr 11 '14 at 16:07

1 Answers1

2

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 =))

Kahler
  • 1,130
  • 6
  • 24
  • thanks for your reply. I came across the link you gave, but I still can't understand if mip-map creation is done with dedicated hardware or not.. – zuuz Apr 25 '14 at 08:25
  • hmmm... well... Ok. I've edited the answer to it's full glory. – Kahler Apr 26 '14 at 19:32
  • okay, thanks for the fuller answer. I've accepted it now :-) – zuuz Apr 28 '14 at 08:06