Package icyllis.arc3d.granite
Class UniformDataGatherer
java.lang.Object
icyllis.arc3d.granite.UniformDataGatherer
- All Implemented Interfaces:
AutoCloseable
Build a uniform data block without reordering, use std140 or std430 layout.
To reduce padding, we only support memory efficient types.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
finish()
Finishes the builder and returns a memory view which implementsIntBuffer.hashCode()
andIntBuffer.equals(Object)
.void
reset()
Reset the builder.void
reset
(int layout) Reset the builder with new layout.void
write1f
(float v0) void
write1i
(int v0) void
write2f
(float v0, float v1) void
write2i
(int v0, int v1) void
write3f
(float v0, float v1, float v2) void
write4f
(float v0, float v1, float v2, float v3) void
write4fv
(int offset, int count, float[] value) void
write4i
(int v0, int v1, int v2, int v3) void
writeMatrix3f
(int offset, float[] value) void
writeMatrix3f
(Matrix3 matrix) void
writeMatrix3f
(Matrixc matrix) void
writeMatrix4f
(int offset, float[] value) void
writeMatrix4f
(Matrix4c matrix) void
writePaintColor
(float r, float g, float b, float a) This is a specialized uniform writing entry point intended to deduplicate the paint color.
-
Field Details
-
Std140Layout
public static final int Std140Layout- See Also:
-
Std430Layout
public static final int Std430Layout- See Also:
-
-
Constructor Details
-
UniformDataGatherer
public UniformDataGatherer(int layout)
-
-
Method Details
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
reset
public void reset()Reset the builder. -
reset
public void reset(int layout) Reset the builder with new layout. -
finish
Finishes the builder and returns a memory view which implementsIntBuffer.hashCode()
andIntBuffer.equals(Object)
. The memory is managed by this object, it is valid until next reset.The reason we chose
IntBuffer
is that uniform data is always 4-byte aligned at least, and using IntBuffer can accelerate the calculation of hashCode and equals. -
write1i
public void write1i(int v0) -
write1f
public void write1f(float v0) -
write2i
public void write2i(int v0, int v1) -
write2f
public void write2f(float v0, float v1) -
write3f
public void write3f(float v0, float v1, float v2) -
write4i
public void write4i(int v0, int v1, int v2, int v3) -
write4f
public void write4f(float v0, float v1, float v2, float v3) -
write4fv
public void write4fv(int offset, int count, float[] value) - Parameters:
offset
- the start index in the arraycount
- the number of float4
-
writeMatrix3f
-
writeMatrix3f
-
writeMatrix3f
public void writeMatrix3f(int offset, float[] value) -
writeMatrix4f
-
writeMatrix4f
public void writeMatrix4f(int offset, float[] value) -
writePaintColor
public void writePaintColor(float r, float g, float b, float a) This is a specialized uniform writing entry point intended to deduplicate the paint color. If a more general system is required, the deduplication logic can be added to the other write methods (and this specialized method would be removed).
-