Stuff

I downloaded and tried out the Visual Studio 2010 CTP a couple of days ago. My experience from the VS2005 and VS2008 betas is that there's a narrow window in time where you can actually get anything fixed, since the CTPs are already released so late in the cycle and a project like Visual Studio has a ton of inertia. The new mantra for VS2010 is apparently "10 is the new 6," which is a reference to the fact that a lot of people still consider Visual C++ 6.0 to be superior to the subsequent releases, including me.

How is it, then?

VS2010 CTP comes as a rather large virtual hard drive (VHD) for Virtual PC 2007 SP1, approximately 26GB. This is because it includes a full Windows Server 2008 evaluation installation as well as a full VS2010 Team Edition CTP install. I ran it on a laptop with 2GB of memory and gave the VM 1GB, which I thought would be sufficient just to try it out. Oh no. The VM absolutely crawled, even before I launched VS2010. I ended up having to disable a bunch of unnecessary services, most notably SQL Server, just to stop the swap death. That got the memory usage of the system down by about 200-300MB, which helped things considerably. It's safe to say, though, that any performance conclusions drawn from this CTP should be taken with a grain of salt... or perhaps a salt lick.

The compiler now understands annotations, and I ported over the UI code from my GPU filter, so you can now add tunable parameters to your .fx file and the filter will automatically create UI for it.

The filter now scans for an FXFilters subdirectory on startup and creates new video filter entries for each .fx file that it finds.

The combined effect of these two changes is that you can now make new VirtualDub filters entirely in vdshader, without writing any C++ code. The individual .fx files show up in the VirtualDub filter list, have their own config dialog, work in batch mode, and can be used just like any other VirtualDub filter written as a regular DLL.

Now, the performance of such a video filter won't be quite as good as a well-optimized C++/asm filter, but I've made some changes on that front, as well. First, vdshader now has an SSE2 JIT which transforms shaders into SoA form and does register allocations, thus running shaders much faster than the scalar x87 JIT. Second, the optimizer has been beefed up substantially and performs more optimizations, such as:

constant folding

unused interpolator elimination

loop invariant hoisting

As an example, in the expression tex2D(src, float2(uv.x, pos*4-1)), the optimizer will identify that (pos*4-1) is an invariant, and hoist both it and the texture V axis clamp/wrap checks out of the loop. These optimizations are particularly useful for tunable parameters, where you can perform complex preconditioning on the parameters and the optimizer will ensure that the calculations are done only once before entering the pixel loop.

There are several other improvements:

Several bugs in the text editor have been fixed and the syntax highlighting has been expanded.

Sampler states are now supported, so you can switch between point/bilinear filtering and wrapping or clamping on each axis. The default is bilinear for compatibility reasons, but point is faster.

The compiler now understands many more intrinsics, including asin(), acos(), atan(), reflect(), saturate(). Several of the existing intrinsics have also been expanded to support vectors.

The shader IL now supports the _sat prefix for saturation to 0-1. I think that's the last PS2.0 feature that was missing, and in theory the engine should now be able to support hoisting D3D PS2.0 bytecode to vdshader IL.

Constant registers c0 and c1 are now auto-bound to float4(width, height, counter, clock) and float4(1/width, 1/height, 0, 0) if they are not otherwise used, and sampler s0 is similarly auto-bound to the source.

A rudimentary preprocessor has been added that understands parameterless #defines.

VDShader can now run all of the stock Media Player Classic pixel shaders without modification.