-
Notifications
You must be signed in to change notification settings - Fork 832
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor chunk update type to be a bitmap instead of an enum, and fix…
… bug where sort tasks upgraded to rebuild tasks would not update the index data if the translucent geometry didn't otherwise require an upload of the index data
- Loading branch information
Showing
7 changed files
with
110 additions
and
114 deletions.
There are no files selected for viewing
65 changes: 0 additions & 65 deletions
65
common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/ChunkUpdateType.java
This file was deleted.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/ChunkUpdateTypes.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,61 @@ | ||
package net.caffeinemc.mods.sodium.client.render.chunk; | ||
|
||
/** | ||
* Important: Whether the task is scheduled immediately after its creation. Otherwise, they're scheduled through | ||
* asynchronous culling that collects non-important tasks. Defer mode: For important tasks, how fast they are going to | ||
* be executed. One or zero frame deferral only allows one or zero frames to pass before the frame blocks on the task. | ||
* Always deferral allows the task to be deferred indefinitely, but if it's important it will still be put to the front | ||
* of the queue. | ||
*/ | ||
public class ChunkUpdateTypes { | ||
public static final int SORT = 0b001; | ||
public static final int REBUILD = 0b010; | ||
public static final int IMPORTANT = 0b100; | ||
public static final int INITIAL_BUILD = 0b1000; | ||
|
||
public static int join(int from, int to) { | ||
return from | to; | ||
} | ||
|
||
public static boolean isSort(int type) { | ||
return (type & SORT) != 0; | ||
} | ||
|
||
public static boolean isRebuild(int type) { | ||
return (type & REBUILD) != 0; | ||
} | ||
|
||
public static boolean isImportant(int type) { | ||
return (type & IMPORTANT) != 0; | ||
} | ||
|
||
public static boolean isInitialBuild(int type) { | ||
return (type & INITIAL_BUILD) != 0; | ||
} | ||
|
||
public static boolean isRebuildWithSort(int type) { | ||
return (isRebuild(type) || isInitialBuild(type)) && isSort(type); | ||
} | ||
|
||
public static DeferMode getDeferMode(int type, DeferMode importantRebuildDeferMode) { | ||
if (isImportant(type)) { | ||
if (isRebuild(type)) { | ||
return importantRebuildDeferMode; | ||
} else { // implies important sort task | ||
return DeferMode.ZERO_FRAMES; | ||
} | ||
} else { | ||
return DeferMode.ALWAYS; | ||
} | ||
} | ||
|
||
public static int getPriorityValue(int type) { | ||
if (isInitialBuild(type)) { | ||
return 0; | ||
} | ||
if (isRebuild(type)) { | ||
return 1; | ||
} | ||
return 2; // sort | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.