Skip navigation.

A Blag About Graphics and Programming

...and Stuff

SSAO: Double Fail

Was playing around with the SSAO shader (using SlimDX), and suddenly started getting "An error occurred while preparing to debug the shader." from PIX, so I enabled the "Debug Version of Direct3d 9" and got this sexy message. I do as I'm told, and find this in the log file:
Frame 000075 ........PRE: <this=0x073523d8>IDirect3DDevice9::DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2)
An unhandled exception occurred.
Notice that this happens in the 75'th frame and I'm not doing any dynamic creation/destruction of resources- everything is created at startup.
The fun thing is that when ran inside Visual Studio, debug output doesn't report any problems, but inside the first effect.Begin() of the first frame the line
HRESULT hr = InternalPointer->Begin( &passCount, 0 );
simply doesn't return- the program stops and memory usage goes through the roof, but no errors or exceptions.

So I think that I've managed to write an uber shader that pwns D3DX, I spend half of the day trying to pinpoint the problem in the shader, but that doesn't take me anywhere. Then I try to isolate the problem by removing stuff from the program and finally realize that it has something to do with my VertexDeclaration:
SlimDX.Direct3D9.VertexElement[] elem= new SlimDX.Direct3D9.VertexElement[]
{
   new SlimDX.Direct3D9.VertexElement(0, 0, SlimDX.Direct3D9.DeclarationType.Float3, SlimDX.Direct3D9.DeclarationMethod.Default, SlimDX.Direct3D9.DeclarationUsage.PositionTransformed, 0),
   SlimDX.Direct3D9.VertexElement.VertexDeclarationEnd
};
Ok, so the problem is that I'm using PositionTransformed and Float3 (xyz) when it should be Float4 (xyzw). I fix that and change my vertex structure accordingly.
Doesn't solve the problem.

Then I change to DeclarationUsage.Position- that seems to work.
I try using FVF instead of vertex declarations:
device.VertexFormat = SlimDX.Direct3D9.VertexFormat.PositionRHW;
//which should be the same as
device->SetFVF(D3DFVF_XYZRHW);
This also doesn't work.
But
device.VertexFormat = SlimDX.Direct3D9.VertexFormat.PositionW;
works.
AGH!1 What the..? Why can't I use transformed position with debug runtime?

Then it dawned on me to try the Reference device... Yep, that hit the spot. Apparently, my old ati/amd/toshiba drivers pooped on themselves.

Spending several hours doing pointless debugging: fail.

SSAO The Wrong WaySmart House 3D Visualization

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies

December 2009
M T W T F S S
November 2009January 2010
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31