Class TextureAllocator
java.lang.Object
dev.pfaff.altargui.texture.TextureAllocator
- All Implemented Interfaces:
AutoCloseable
Arrays: | 1 | 2 | 3 |
Active: | D | U* | U |
States:
- D clean for drawing
- U accepting uploads
- U* finishing upload
When a buffer with state U*
is finished, it transitions to state D
, the previous buffer
transitions to state U
, and the next buffer transitions to state U*
. Thanks to this model, the
states of all three buffers may be represented using a single 2-bit index.
|---|---|---|
| A | B | C |
|---|---|---|
Initial state:
- A) Drawing
- B) Finishing (nothing)
- C) Uploading
Next state, triggered on job submission to C:
- A) Uploading
- B) Drawing
- C) Finishing (at least 1 job)
Next state, triggered on job completion in C:
- A) Finishing (possibly nothing)
- B) Uploading
- C) Drawing
Next state, triggered on job completion in A (if any) and job submission to B:
- A) Drawing
- B) Finishing (possibly nothing)
- C) Uploading
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final byte
static final int
The minimum allocation size in pixels. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionalloc
(LoadableTexture key) Gets a shader to the given texture.void
close()
void
dump()
void
reset()
-
Field Details
-
TBS_COUNT
public static final byte TBS_COUNT- See Also:
-
MAX_TEXTURE_SIZE
public static final int MAX_TEXTURE_SIZE -
UNIT
public static final int UNITThe minimum allocation size in pixels. Herein we often measure in "units" rather than pixels for efficiency.
-
-
Constructor Details
-
TextureAllocator
public TextureAllocator(int size, int initialLayers) - Parameters:
size
- the width and height of each layer.
-
-
Method Details
-
reset
public void reset() -
boundForDraw
-
alloc
Gets a shader to the given texture. If not loaded, the texture will be loaded and a slot allocated for it.
This method must only be called from the main thread.
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
dump
public void dump()
-