PDA

View Full Version : GUI System Advice



Scribe
07-12-2009, 06:10 AM
Hi guys,

I'm in the process of creating a GUI system in openGL that makes use of vertexes to create a flat rectangle on which to render my interface boxes.

I am attempting to work towards openGL 3.1 compliance by using VBOs however have a question. Which method of updating rectangle positions would you think is more efficient/correct?

1. When a parent box moves containing child boxes, should the parent box update a translate matrix and upload it to the shader program via glUniform (I think I'm correct in saying this is how it works in ogl3.1)

2. Should I update the VBOs of the child boxes to contain the new absolute co-ordinates?

3. Is there a better way than method 1 and 2?

Many thanks for any help.

Hlz
07-12-2009, 12:08 PM
IMO (2) is reasonable. Transform your 2D scene graph on the CPU. Unless your UI is really complex this usually amounts to a single, parent-relative translation, which you can simply fold into your vertex buffer as you go.

In general lots of shader variable updates are going to put a hurt on your perf.

Scribe
07-12-2009, 01:27 PM
I was thinking that may be the case but was unsure, many thanks.

On a side note then how were matrices implemented in OGL2.1? Most people translate between models, were they just implemented as uniforms underneath or is there a faster method. Would storing them in a general buffer be faster - or does it take longer to read those... I'm guessing uniforms are cached closer to the shader cores.

Ilian Dinev
07-12-2009, 03:00 PM
Try things out. For me, on any modern nV and ATi card (since GF5xxx and R9550), here's the optimum approach:
- Simplistic ARB-asm shaders, no transformation done on gpu.
- Rectangles instead of texture2D.
- Clip and transform quads on cpu
- upload triangles via gl*Pointer
- keep batch-arrays in L1 cache
- this all will make best use of the vast AGP/PCIe bandwidth, < 1% cpu usage, for thousands of quads.

- only one dirty rectangle. Adding more just increases the size of the current one (bounding box).
- the dirty area is setup as primary clipping rectangle. Reminder: clipping is done in software.

The stuff above is suitable for my needs, might be unsuitable for yours.