Class UniformDataGatherer

java.lang.Object
icyllis.arc3d.granite.UniformDataGatherer
All Implemented Interfaces:
AutoCloseable

public class UniformDataGatherer extends Object implements AutoCloseable
Build a uniform data block without reordering, use std140 or std430 layout. To reduce padding, we only support memory efficient types.
  • Field Details

  • Constructor Details

    • UniformDataGatherer

      public UniformDataGatherer(int layout)
  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • reset

      public void reset()
      Reset the builder.
    • reset

      public void reset(int layout)
      Reset the builder with new layout.
    • finish

      public IntBuffer finish()
      Finishes the builder and returns a memory view which implements IntBuffer.hashCode() and IntBuffer.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 array
      count - the number of float4
    • writeMatrix3f

      public void writeMatrix3f(Matrixc matrix)
    • writeMatrix3f

      public void writeMatrix3f(Matrix3 matrix)
    • writeMatrix3f

      public void writeMatrix3f(int offset, float[] value)
    • writeMatrix4f

      public void writeMatrix4f(Matrix4c matrix)
    • 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).