Created
October 19, 2012 01:03
-
-
Save rygorous/3915675 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static RADINLINE bool is_fence_pending(GDrawFence fence) | |
| { | |
| U32 retired = get_gpu_fence(); | |
| // everything between "retired" (exclusive) and "next_fence_counter" | |
| // (inclusive) is pending. everything else is definitely done. | |
| // | |
| // we need to be careful about this test since the "fence" value | |
| // coming in is, for all practical purposes, an arbitrary U32. our | |
| // fence counter might have wrapped around multiple times since we last | |
| // used a resource that gets freed, for instance! so if we report a | |
| // fence ID as pending that's not actually in flight, we might end up | |
| // with an infinite wait. | |
| // | |
| // this is a bit subtle since it depends on unsigned wraparound for us | |
| // to do the right thing. | |
| // number of pending fences (next_fence_counter has, by definition, not been written yet) | |
| U32 num_pending = gdraw->next_fence_counter - retired; | |
| // position of the current fence in the "list of pending fences", counting | |
| // from end (i.e. the "youngest" fence that we haven't even issued yet) | |
| U32 pos_in_pending_list = gdraw->next_fence_counter - fence.uinteger; | |
| return pos_in_pending_list < num_pending; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment