Kenneth Ostby wrote:
I see the point in vector load instructions, however, as a computer
architect, I'm wondering if there is other ways to solve this. Mainly,
cause I want to expose a simple ISA to the software developers (
Software developers here being the compilers and OpenGL driver
developers ).
Sample GLSL code from the orange book:
vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex;
vec3 ecPosition3 = (vec3(ecPosition)) / ecPosition.w;
vec3 VP = vec3(gl_LightSource[0].position) - ecPosition3;
VP = normalize(VP);
LightIntensity = DiffuseContribution * diffuse +
SpecularContribution * spec;
MCposition = gl_Vertex.xy;
In GLSL / Cg / HLSL the number of components in each vector or
matrix is fixed at declaration time. The number of components
used in each instruction is:
implicit from type : gl_ModelViewMatrix * gl_Vertex
conversion to type : vec3(ecPosition)
named components : gl_Vertex.xy
The compiler writer always knows exactly how big each operand
is, how many components it has, and which ones are needed. A
vector instruction set will be the simplest ISA for software
developers.
(Don't overlook the need for "swizzling": it is perfectly valid
to write
vec4 foo = gl_Color * gl_Vertex.xxzz
which says to multiply the first two RGBA components of gl_Color
by the vertex x coord the last two RGBA by vertex z coord.)
--
Hugh Fisher
CECS, ANU
_______________________________________________
Open-graphics mailing list
[email protected]
http://lists.duskglow.com/mailman/listinfo/open-graphics
List service provided by Duskglow Consulting, LLC (www.duskglow.com)