Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

SlimTimmy

Occlusion Query

This topic is 5227 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I'm trying to use the new feature in DX9, Occlusion Queries. But I have a problem: IDirect3DQuery::GetData always(!!) returns S_FALSE! I have a Geforce 4 Ti 4200, driver is relatively new. Here's some of my Code (for testing purposes): m_RenderSystem.ClearScreen(true,true); m_VB->Bind(); m_RenderSystem.GetDevice()->SetFVF(sVertex::FVF); m_RenderSystem._SetCullMode(CULL_NONE); cRenderOperation Op; Op.VertexBuffer=m_VB; Op.Operation=cRenderOperation::OP_TRIANGLE_LIST; m_Query->Begin(); m_RenderSystem._Render(Op); m_Query->End(); uint Count; if(m_Query->GetVisiblePixels(Count)) cLog<<"Visible Pixels: "<< Count <<"\n"; [edited by - SlimTimmy on February 22, 2004 3:29:48 PM] [edited by - SlimTimmy on February 25, 2004 11:06:22 AM]

Share this post


Link to post
Share on other sites
Advertisement
How are you using the GetData() call? It should be like this:
 while (d3dQuery->GetData((void *) &occlusionVariable, sizeof(DWORD), D3DGETDATA_FLUSH) == S_FALSE);  

You need the while loop because GetData() is asynchronous, so it normally doesn''t succeed the first time.

Share this post


Link to post
Share on other sites
Ok, now it works, but is it really necessary to use D3DGETDATA_FLUSH? I thought, that such a call can result in a lost device.

Share this post


Link to post
Share on other sites
quote:
Original post by SlimTimmy
Ok, now it works, but is it really necessary to use D3DGETDATA_FLUSH? I thought, that such a call can result in a lost device.

Flushing forces D3D to send the query commands to the driver. Without flushing, you could wait a little longer for d3d to pass the commands to the driver, then for the driver to do the query.

Muhammad Haggag
[edit]Correction[/edit]

[edited by - Coder on February 23, 2004 6:17:41 AM]

Share this post


Link to post
Share on other sites
That would probably depend on you card/driver settings, because every driver should have a different FIFO pipeline.
Generally I would advise you to send all your occlusion queries at once, and then flush the FIFO. This way the Queries will be queued up and you only need to flush once.


Hey, SlimTimmy, I know you from the ZFX forums, don''t I? ^^

cya,
hWnd

Share this post


Link to post
Share on other sites
When wouldn''t you use the D3DGETDATA_FLUSH-parameter?
I did a test and just passed 0 as the last parameter of the GetData-method, the condition in the while-loop (see above) never evaluated to true! Is this a normal behaviour?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:

When wouldn''t you use the D3DGETDATA_FLUSH-parameter?
I did a test and just passed 0 as the last parameter of the GetData-method, the condition in the while-loop (see above) never evaluated to true! Is this a normal behaviour?



That is the behaviour I would expect, because the query is never sent to the video card.

The driver internally has a FIFO queue where all commands that have to be sent to the card are stored. When the queue is full, it will be flushed, i.e. sent to the card. There are some operations that cause the command queue to flush, no matter if it''s full or not. These commands include swapping front and back buffer and render target changes. In GL there is also a convenient way to flush the pipeline manually, using glFlush(). I do not know of a similar way to do this in D3D.

So in your case, the query is added to the queue, but since it is never flushed the query is never issued.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!