Vertex Shader 2.0 Support

The R300 also supports the Vertex Shader 2.0 specification, which is a part of Microsoft’s DX9 spec. Along with this, the Hardware Displacement Mapping technology from Matrox’s Parhelia is also supported by the R300, though it will go unused for a while until developers begin taking advantage of it.

The major benefits of the 2.0 spec include flow control and an increase in the number of instructions that can be executed per pass. Flow control support means that vertex shader programs can now contain loops, jumps and subroutines, which are very important to keep shader programs small and efficient by avoiding repetition of code and reducing instruction count.

The benefit of flow control can easily be seen by the following example:

Let’s say we wanted to increment a variable ‘x’ by 1 and after incrementing it by ‘1’ we were going to execute a command the depended on the value of ‘x’. Let’s also assume that in order for this shader program to work that we needed to do this for 5 distinct values of ‘x’.

Without flow control, in this case loops, the program would look like this:


x = x + 1
ExecuteCommand(x)
x = x + 1
ExecuteCommand(x)
x = x + 1
ExecuteCommand(x)
x = x + 1
ExecuteCommand(x)
x = x + 1
ExecuteCommand(x)

Now using Vertex Shader 2.0 the same can be done using a loop in two lines:

for (x=0;x<5;x++)
ExecuteCommand(X);

The first line initializes a variable ‘x’, increments it by 1 for every run of the loop and continues to execute the next command while the value of ‘x’ is less than 5.

The latter method obviously makes more sense, is easier to write and significantly reduces the size of your code. Imagine writing a similar program that required 100 distinct values of ‘x’, the code just to do that would be 200 lines long but with loops it’s still just two lines.

The new Vertex Shader specification also allows for up to 1024 instructions in a single pass.

Vertex Processing – Twice GeForce4’s Triangle Throughput Eight Pixel Rendering Pipelines – The DX9 Era Begins
Comments Locked

0 Comments

View All Comments

Log in

Don't have an account? Sign up now