-
-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial support for deferred programs, refactor buffer flipping logic
- Loading branch information
1 parent
fa08bef
commit b3e655f
Showing
2 changed files
with
110 additions
and
46 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/main/java/net/coderbot/iris/postprocess/BufferFlipper.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package net.coderbot.iris.postprocess; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import it.unimi.dsi.fastutil.ints.IntIterator; | ||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet; | ||
import it.unimi.dsi.fastutil.ints.IntSet; | ||
|
||
public class BufferFlipper { | ||
private final IntSet flippedBuffers; | ||
|
||
public BufferFlipper() { | ||
this.flippedBuffers = new IntOpenHashSet(); | ||
} | ||
|
||
public void flip(int target) { | ||
if (!flippedBuffers.remove(target)) { | ||
// If the target wasn't in the set, add it to the set. | ||
flippedBuffers.add(target); | ||
} | ||
} | ||
|
||
/** | ||
* Returns true if this buffer is flipped. | ||
* | ||
* If this buffer is not flipped, then users should write to the alternate variant and read from the main variant. | ||
* | ||
* If this buffer is flipped, then users should write to the main variant and read from the alternate variant. | ||
*/ | ||
public boolean isFlipped(int target) { | ||
return flippedBuffers.contains(target); | ||
} | ||
|
||
public IntIterator getFlippedBuffers() { | ||
return flippedBuffers.iterator(); | ||
} | ||
|
||
public ImmutableSet<Integer> snapshot() { | ||
return ImmutableSet.copyOf(flippedBuffers); | ||
} | ||
} |
This file contains 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