-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable VK12 VMA Features + Misc. Shader/Optimisation tweaks
- Loading branch information
Showing
8 changed files
with
153 additions
and
82 deletions.
There are no files selected for viewing
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
99 changes: 99 additions & 0 deletions
99
src/main/java/net/vulkanmod/render/chunk/util/StaticQueue.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,99 @@ | ||
package net.vulkanmod.render.chunk.util; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Iterator; | ||
import java.util.function.Consumer; | ||
|
||
public class StaticQueue<T> implements Iterable<T> { | ||
final T[] queue; | ||
int position = 0; | ||
int limit = 0; | ||
final int capacity; | ||
|
||
public StaticQueue() { | ||
this(1024); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public StaticQueue(int initialCapacity) { | ||
this.capacity = initialCapacity; | ||
|
||
this.queue = (T[])(new Object[capacity]); | ||
} | ||
|
||
public boolean hasNext() { | ||
return this.position < this.limit; | ||
} | ||
|
||
public T poll() { | ||
T t = this.queue[position]; | ||
this.position++; | ||
|
||
return t; | ||
} | ||
|
||
public void add(T t) { | ||
if(t == null) | ||
return; | ||
|
||
if(limit == capacity) throw new RuntimeException("Exceeded size: "+this.capacity); | ||
this.queue[limit] = t; | ||
|
||
this.limit++; | ||
} | ||
|
||
public int size() { | ||
return limit; | ||
} | ||
|
||
public void clear() { | ||
this.position = 0; | ||
this.limit = 0; | ||
} | ||
|
||
public Iterator<T> iterator(boolean reverseOrder) { | ||
return reverseOrder ? new Iterator<>() { | ||
int pos = StaticQueue.this.limit - 1; | ||
final int limit = -1; | ||
|
||
@Override | ||
public boolean hasNext() { | ||
return pos > limit; | ||
} | ||
|
||
@Override | ||
public T next() { | ||
return queue[pos--]; | ||
} | ||
} | ||
: new Iterator<>() { | ||
int pos = 0; | ||
final int limit = StaticQueue.this.limit; | ||
|
||
@Override | ||
public boolean hasNext() { | ||
return pos < limit; | ||
} | ||
|
||
@Override | ||
public T next() { | ||
return queue[pos++]; | ||
} | ||
}; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public Iterator<T> iterator() { | ||
return iterator(false); | ||
} | ||
|
||
@Override | ||
public void forEach(Consumer<? super T> action) { | ||
for(int i = 0; i < this.limit; ++i) { | ||
action.accept(this.queue[i]); | ||
} | ||
|
||
} | ||
} |
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.