On 31/05/12 04:43, [email protected] wrote:
loop counters ?
compute array indices ?

On 31/05/12 05:01, Timothy Normand Miller wrote:
To your list, I can add memory addresses, address calculations, and coordinates.

An OpenGL implementation needs surprisingly few integer
operations.

The first few Shader Models (MS terminology, we're at
#5 now) didn't have any programmer-visible integer vars.
Integers (and booleans) got added in later versions, but
there's nothing that says the implementation can't do
everything by converting to float.

Loop counters can be implemented in floating point, it's
not going to be a bottleneck. Same for array indices.

Simplifying only slightly, OpenGL shaders read memory
from texture maps and write frame buffer memory. All the
address calcs for these are in floating point. Texture
coords are 0.0 .. 1.0, interpolated between vertices in
floating point. There's no integer conversion until the
final texture fetch, because the integer dimensions of
the texture itself aren't known when the shader is compiled.
Pixel coordinates are likewise delivered from OpenGL in
floating point, matrix transformed in floating point, and
interpolated. The fragment shader that does the final
write can't modify the floating point X,Y coords.

Instruction fetches are from addresses known at compile
time, there's no self modifying code. Nor are there any
computed jumps. The latest GPUs do allow branches through
a pointer, but the pointer is restricted to subroutine
addresses known at compile/link time.

There are a couple of visible integer values to shader
programmers, the instance ID and invocation ID. Both of
these are simple counters that increment for each batch
or each vertex within a batch. Again, the shader can't
change them.

OpenCL makes heavier use of integers as array indices
so there are more adds, multiplies, etc. Also more likely
that an OpenCL program will be crunching integer data.


Please note I'm not saying that you can't build a GPU
without any integer operations. I do think that saying
"this is for OpenGL and we'll only use integers if
absolutely, positively, necessary" will be very useful
in keeping the design focused and achievable.

        cheers,
        Hugh Fisher

_______________________________________________
Open-graphics mailing list
[email protected]
http://lists.duskglow.com/mailman/listinfo/open-graphics
List service provided by Duskglow Consulting, LLC (www.duskglow.com)

Reply via email to