   [DX9] DepthStencil look ??
  Hi,I need to retrieve the overdraw to verify how efficient is the z prepass. Particularly, I want to count how many pixels get shaded after z prepass (I'm getting crazy with it).A method I read on a book is by setting the stencil buffer to count how many times a pixel is drawn. The you have to look it, and read it (averaging counts etc..)Problem is: how do I look the device depthStencil buffer ? I can't.I tried using a new one (creted with CreateDepthStencilSurface) but I can't look it neither.Format is D3DFMT_D24S8.--After a z prepass one expects the overdraw to be one, because a pixel cannot be computer more than once. However, it seems that this rule doesn't hold in my engine... it has no sense.thanks !   
  Alternatively, does anyone know how to compute the overdraw ?   ;  If you just want to know how many pixels were actually drawn, you can use an occlusion query. Create a query of type D3DQUERYTYPE_OCCLUSION, call Issue before all of your drawing after the z prepass, and then call Issue again when you're done. The value you get from the query will be the number of pixels that passed the depth/stencil test.However the statistic you're probably really interested in is how many pixel shader executions occurred during your second pass. This number is dependent on the early-z hardware in the GPU, as well as the contents of the depth/stencil buffer itself. Unfortunately D3D9 doesn't expose a way to get this information (D3D10 and D3D11 do). I believe you can get this info through Nvidia's PerfHUD/PerfSDK, and you can probably get it through the ATI equivalents.   ;  An old-school way to visualise overdraw is to override all materials to be unlit, dark-grey with additive blending. Bright pixels have been drawn several times.   ;Quote:Original post by MJPHowever the statistic you're probably really interested in is how many pixel shader executions occurred during your second pass. This number is dependent on the early-z hardware in the GPU, as well as the contents of the depth/stencil buffer itself. Unfortunately D3D9 doesn't expose a way to get this information (D3D10 and D3D11 do). I believe you can get this info through Nvidia's PerfHUD/PerfSDK, and you can probably get it through the ATI equivalents.That's what I want: the pixel drawn in the second pass. Perhaps I will try your query method, but few minutes ago I figured a trivial simple method to see if z prepass works: ten huge quads one after the other. Watching them, the FPS has a huge drop.With PerfHUD I found out that the GPU is drawing exactly 10 times each pixel => z prepass is not working at all... WHY ?!At the beginning of the second pass I have:->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);Can not be !! :°((so PerfHUD seems to be sufficient to obtain this kind of data)Thanks MJP !!Quote:Original post by HodgmanAn old-school way to visualise overdraw is to override all materials to be unlit, dark-grey with additive blending. Bright pixels have been drawn several times.this is a cool way to figure it !Actually, as I said, right now I'm sure: I'm drawing many times the same pixel without any reason...   