Heavy computing with GLSL – Part 5: Emulated quadruple precision

It’s been a while since my last post about the wonders of modern GPU computing with GLSL but the following concept really took a lot of time to get it to work as intended.

Today I’m going to introduce emulated quadruple floating point precision (quad-single-precision) with GLSL. I will use the well-known mandelbrot set to demonstrate the concept. The sourcecode is available as usual.

Continue reading

Posted in GLSL, OpenGL, Programming | Tagged , , | 6 Comments

Heavy computing with GLSL – Part 4: NVIDIA optimizations

In my recent post about double emulation in GLSL I tested the shader code on my ATI GPU. That was a mistake… Mauna pointed out that the double emulation shader does not work on NVIDIA GPUs. I checked that and it proved that this was not a single problem on a specific card.

I reckon that it must be some weird optimization on NVIDIA cards that break the emulation code. So I searched for a way to disable these optimizations. After some googling I found an old blog entry by Cyril Crassin (check out his new blog if you are into 3D graphics) which helped me out with this problem.

To turn off the NVIDIA optimizations I had to add the following lines to the shader code.

1
2
#pragma optionNV(fastmath off)
#pragma optionNV(fastprecision off)
#pragma optionNV(fastmath off)
#pragma optionNV(fastprecision off)

Now it should work fine with NVIDIA GPUs. Let me know if there are still some issues.

Download updated version: GLSL_EmuMandel.zip

I have also found a handy tool called NVEmulate to examine the GLSL compiler output and other stuff to analyze GLSL assembly on NVIDIA GPUs.

Posted in GLSL, OpenGL, Programming | Tagged , , | 2 Comments

Heavy computing with GLSL – Part 3: Hardware double precision

Usually GPUs do not support double precision. However, since it has become popular to utilize GPUs for computations of all sorts and the introduction of languages to support these efforts (like OpenCL, Cuda) it has become more and more important to support greater precision.

To improve performance of our mandelbrot project a little bit further, I will show how to use real, hardware accelerated double precision arithmetics.

Continue reading

Posted in GLSL, OpenGL, Programming | Tagged , , | 6 Comments

Heavy computing with GLSL – Part 2: Emulated double precision

Introduction

In my last post I introduced a simple mandelbrot fractal shader with GLSL. Unfortunately Intentionally, the shader code uses single precision floating point variables which ensures great performance but limits the zoom factor to about 17 before the lack of accuracy of the floating point variables takes over and all you get is a block-ish image of some sort at greater zoom levels:

Since I am very interested to discover the beauty of our mandelbrot set in close detail I will improve the existing shader with emulated double precision variables (aka: double-single) and see how far I can push it.

Continue reading

Posted in Programming | Tagged , , | 16 Comments

Heavy computing with GLSL – Part 1

Introduction

In my previous GLSL post I have shown how to draw a white quad. Since this is not the greatest visual experience, I will show something more interesting you can do with shaders in this post.

I have chosen the famous mandelbrot fractal. It’s nice and colorful. Quite a fine eyecatcher.

Download the code: GLSL_SimpleMandel (windows version)

The code was tested on WinXP/ATI-GPU and Win7/NVidia-GPU

The final result looks like this:

Mandelbrot GLSL Shader - Main Window

Continue reading

Posted in Programming | Tagged , , | 1 Comment

Hello GLSL – GLSL Shader App with Qt

Introduction

In this tutorial we will extend the previous tutorial and make use of a Shader written in GLSL to fill our spinning quad. GLSL is a C-like language you can use to execute code on your GPU (aka graphics card). More sophisticated effects can be achieved with this technique.

The point of this tutorial is to show how Qt supports shader programs and how to use them in your application.

Download the source: Hello_GLSL.zip

Application window: Continue reading

Posted in Programming | Tagged , , | Leave a comment

Hello Quad (basic OpenGL App with Qt)

Introduction

In this first tutorial we will create a simple (I mean really simple…) Qt program to render OpenGL graphics (spinning quad). I will extend the programs you find in the Qt boxes demo and Qt OpenGL examples with a separate thread that does the actual redering to be independent (in terms of framerate) from any GUI interaction or other Qt events.

Sourcecode: Tut_01_OpenGL_Setup.zip (Qt-Project files).

The result of this tutorial looks like this:Application Window Continue reading

Posted in Programming | Tagged , , | 8 Comments