SSAO: Double Fail
Friday, 16. January 2009, 22:22:03
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:
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
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:
Doesn't solve the problem.
Then I change to DeclarationUsage.Position- that seems to work.
I try using FVF instead of vertex declarations:
But
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.
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.

How to use Quote function: