Jump to content
  • Advertisement
Sign in to follow this  
hmcen

FBO+Occlusion Query

This topic is 4095 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

Hi, all I came up with a strange problem when use FBO with occlusion query: My program simply draw a triangle and count how many fragments generated using occlusion query. I don't use any shaders, and turn off detph test. OK, in the first pass i render the triangle and count its fragments. In the second pass, i do exactly as the first pass, except i use FBO and render it to texture. But as i rotate the triangle, the fragment count in first pass and the second are not always identical (differs in 1-2 fragments), which in my understanding they should always the same. When i disable render to texture in second pass, simply comment out the FBO binding, it works as i expected. Now i doubt whether render to texture and render normally differ in the way that a triangle rasterized into fragments, as my experiment told me the total fragments are not always the same. Core part of my code:
void display ( void )
{
    //first pass
    glBeginQueryARB( GL_SAMPLES_PASSED_ARB, query );
    drawTriangle();
    glEndQueryARB( GL_SAMPLES_PASSED_ARB );
    glGetQueryObjectuivARB( query, GL_QUERY_RESULT_ARB, &fragmentCount1);

    //second pass
    fb->BindBuffer();  //Bind FBO
    glBeginQueryARB( GL_SAMPLES_PASSED_ARB, query );
    drawTriangle();
    glEndQueryARB( GL_SAMPLES_PASSED_ARB );
    glGetQueryObjectuivARB( query, GL_QUERY_RESULT_ARB, &fragmentCount2);
    fb->UnbindBuffer();  //Unbind FBO

    printf("difference = %d\n", fragmentCount1-fragmentCount2 );

    glutSwapBuffers();
}


PS: 1. There should be no problem with occlusion query itself. 2. The setup of FBO in my program should be ok. 3. In both pass, the drawTriangle() is exactly the same. 4. My GPU is Geforce 6800, hope not a hardware bug. If possible, can anyone write and test this in your machine? I'm grateful to hear your result. Thanks a lot!

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!