Package icyllis.arc3d.engine

# Class UniformDataManager

java.lang.Object
icyllis.arc3d.core.RefCnt
icyllis.arc3d.engine.UniformDataManager

All Implemented Interfaces:
  `RefCounted`

Direct Known Subclasses:
  `GLUniformDataManager`

public abstract class UniformDataManager extends RefCnt
Manages the resources used by a shader program. The resources are objects the program uses to communicate with the application code.

The `UniformDataManager` is used to store uniforms for a program in a CPU buffer that can be uploaded to a UBO. This currently assumes uniform layouts that are compatible with OpenGL, Vulkan, and D3D12. It could be used more broadly if this aspect was made configurable.

The default implementation assumes the block uses std140 layout. For Vulkan, if push-constants is used, subclasses should be configured to std430 layout. Uniforms here means that they can be uploaded to UBO, and does not include opaque types such as samplers, which are updated separately from this class.

See Also:
  - `UniformHandler`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final long`
  `mUniformData`
  `protected final int[]`
  `mUniforms`
  `protected boolean`
  `mUniformsDirty`
  `protected final int`
  `mUniformSize`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `UniformDataManager(int uniformCount, int uniformSize)`
  Constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `deallocate()`
  Override this method to invoke de-allocation of the underlying resource.
  `protected long`
  `getBufferPtrAndMarkDirty(int uni)`
  `void`
  `set1f(int u, float v0)`
  Specifies the value of a float uniform variable for the current program object.
  `void`
  `set1fv(int u, int offset, int count, float[] value)`
  Array version of `set1fv(int, int, long)`.
  `void`
  `set1fv(int u, int count, long value)`
  Specifies the value of a single float uniform variable or a float uniform variable array for the current program object.
  `void`
  `set1i(int u, int v0)`
  Specifies the value of an int, uint or bool uniform variable for the current program object.
  `void`
  `set1iv(int u, int offset, int count, int[] value)`
  Array version of `set1iv(int, int, long)`.
  `void`
  `set1iv(int u, int count, long value)`
  Specifies the value of a single int, uint or bool uniform variable or an int, uint or bool uniform variable array for the current program object.
  `void`
  `set2f(int u, float v0, float v1)`
  Specifies the value of a vec2 uniform variable for the current program object.
  `void`
  `set2fv(int u, int offset, int count, float[] value)`
  Array version of `set2fv(int, int, long)`.
  `void`
  `set2fv(int u, int count, long value)`
  Specifies the value of a single vec2 uniform variable or a vec2 uniform variable array for the current program object.
  `void`
  `set2i(int u, int v0, int v1)`
  Specifies the value of an ivec2, uvec2 or bvec2 uniform variable for the current program object.
  `void`
  `set2iv(int u, int offset, int count, int[] value)`
  Array version of `set2iv(int, int, long)`.
  `void`
  `set2iv(int u, int count, long value)`
  Specifies the value of a single ivec2, uvec2 or bvec2 uniform variable or an ivec2, uvec2 or bvec2 uniform variable array for the current program object.
  `void`
  `set3f(int u, float v0, float v1, float v2)`
  Specifies the value of a vec3 uniform variable for the current program object.
  `void`
  `set3fv(int u, int offset, int count, float[] value)`
  Array version of `set3fv(int, int, long)`.
  `void`
  `set3fv(int u, int count, long value)`
  Specifies the value of a single vec3 uniform variable or a vec3 uniform variable array for the current program object.
  `void`
  `set3i(int u, int v0, int v1, int v2)`
  Specifies the value of an ivec3, uvec3 or bvec3 uniform variable for the current program object.
  `void`
  `set3iv(int u, int offset, int count, int[] value)`
  Array version of `set3iv(int, int, long)`.
  `void`
  `set3iv(int u, int count, long value)`
  Specifies the value of a single ivec3, uvec3 or bvec3 uniform variable or an ivec3, uvec3 or bvec3 uniform variable array for the current program object.
  `void`
  `set4f(int u, float v0, float v1, float v2, float v3)`
  Specifies the value of a vec4 uniform variable for the current program object.
  `void`
  `set4fv(int u, int offset, int count, float[] value)`
  Array version of `set4fv(int, int, long)`.
  `void`
  `set4fv(int u, int count, long value)`
  Specifies the value of a single vec4 uniform variable or a vec4 uniform variable array for the current program object.
  `void`
  `set4i(int u, int v0, int v1, int v2, int v3)`
  Specifies the value of an ivec4, uvec4 or bvec4 uniform variable for the current program object.
  `void`
  `set4iv(int u, int offset, int count, int[] value)`
  Array version of `set4iv(int, int, long)`.
  `void`
  `set4iv(int u, int count, long value)`
  Specifies the value of a single ivec4, uvec4 or bvec4 uniform variable or an ivec4, uvec4 or bvec4 uniform variable array for the current program object.
  `void`
  `setMatrix2fv(int u, int offset, int count, float[] value)`
  Array version of `setMatrix2fv(int, int, long)`.
  `void`
  `setMatrix2fv(int u, int count, long value)`
  Specifies the value of a single mat2 uniform variable or a mat2 uniform variable array for the current program object.
  `void`
  `setMatrix3f(int u, Matrix3 matrix)`
  Convenience method for uploading a Matrix to a 3x3 matrix uniform.
  `void`
  `setMatrix3f(int u, Matrixc matrix)`
  Convenience method for uploading a Matrix to a 3x3 matrix uniform.
  `void`
  `setMatrix3fv(int u, int offset, int count, float[] value)`
  Array version of `setMatrix3fv(int, int, long)`.
  `void`
  `setMatrix3fv(int u, int count, long value)`
  Specifies the value of a single mat3 uniform variable or a mat3 uniform variable array for the current program object.
  `void`
  `setMatrix4f(int u, Matrix4 matrix)`
  Convenience method for uploading a Matrix4 to a 4x4 matrix uniform.
  `void`
  `setMatrix4fv(int u, int offset, int count, float[] value)`
  Array version of `setMatrix4fv(int, int, long)`.
  `void`
  `setMatrix4fv(int u, int count, long value)`
  Specifies the value of a single mat4 uniform variable or a mat4 uniform variable array for the current program object.

  ### Methods inherited from class icyllis.arc3d.core.RefCnt

  `create, create, getRefCnt, getRefCntAcquire, getRefCntVolatile, move, move, ref, unique, unref`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### mUniforms

    protected final int[] mUniforms

  - ### mUniformSize

    protected final int mUniformSize

  - ### mUniformData

    protected final long mUniformData

  - ### mUniformsDirty

    protected boolean mUniformsDirty

- ## Constructor Details

  - ### UniformDataManager

    public UniformDataManager(int uniformCount, int uniformSize)
    Constructor.
    Parameters:
      `uniformCount` - the number of uniforms
      `uniformSize` - the uniform block size in bytes

- ## Method Details

  - ### deallocate

    protected void deallocate()
    Description copied from class: `RefCnt`
    Override this method to invoke de-allocation of the underlying resource.
    Specified by:
      `deallocate` in class `RefCnt`

  - ### set1i

    public void set1i(int u, int v0)
    Specifies the value of an int, uint or bool uniform variable for the current program object.

  - ### set1iv

    public void set1iv(int u, int count, long value)
    Specifies the value of a single int, uint or bool uniform variable or an int, uint or bool uniform variable array for the current program object.
    Parameters:
      `count` - the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array
      `value` - a pointer to an array of `count` values that will be used to update the specified uniform variable

  - ### set1iv

    public void set1iv(int u, int offset, int count, int[] value)
    Array version of `set1iv(int, int, long)`.
    Parameters:
      `offset` - the start index in the array

  - ### set1f

    public void set1f(int u, float v0)
    Specifies the value of a float uniform variable for the current program object.

  - ### set1fv

    public void set1fv(int u, int count, long value)
    Specifies the value of a single float uniform variable or a float uniform variable array for the current program object.
    Parameters:
      `count` - the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array
      `value` - a pointer to an array of `count` values that will be used to update the specified uniform variable

  - ### set1fv

    public void set1fv(int u, int offset, int count, float[] value)
    Array version of `set1fv(int, int, long)`.
    Parameters:
      `offset` - the start index in the array

  - ### set2i

    public void set2i(int u, int v0, int v1)
    Specifies the value of an ivec2, uvec2 or bvec2 uniform variable for the current program object.

  - ### set2iv

    public void set2iv(int u, int count, long value)
    Specifies the value of a single ivec2, uvec2 or bvec2 uniform variable or an ivec2, uvec2 or bvec2 uniform variable array for the current program object.
    Parameters:
      `count` - the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array
      `value` - a pointer to an array of `count` values that will be used to update the specified uniform variable

  - ### set2iv

    public void set2iv(int u, int offset, int count, int[] value)
    Array version of `set2iv(int, int, long)`.
    Parameters:
      `offset` - the start index in the array

  - ### set2f

    public void set2f(int u, float v0, float v1)
    Specifies the value of a vec2 uniform variable for the current program object.

  - ### set2fv

    public void set2fv(int u, int count, long value)
    Specifies the value of a single vec2 uniform variable or a vec2 uniform variable array for the current program object.
    Parameters:
      `count` - the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array
      `value` - a pointer to an array of `count` values that will be used to update the specified uniform variable

  - ### set2fv

    public void set2fv(int u, int offset, int count, float[] value)
    Array version of `set2fv(int, int, long)`.
    Parameters:
      `offset` - the start index in the array

  - ### set3i

    public void set3i(int u, int v0, int v1, int v2)
    Specifies the value of an ivec3, uvec3 or bvec3 uniform variable for the current program object.

  - ### set3iv

    public void set3iv(int u, int count, long value)
    Specifies the value of a single ivec3, uvec3 or bvec3 uniform variable or an ivec3, uvec3 or bvec3 uniform variable array for the current program object.
    Parameters:
      `count` - the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array
      `value` - a pointer to an array of `count` values that will be used to update the specified uniform variable

  - ### set3iv

    public void set3iv(int u, int offset, int count, int[] value)
    Array version of `set3iv(int, int, long)`.
    Parameters:
      `offset` - the start index in the array

  - ### set3f

    public void set3f(int u, float v0, float v1, float v2)
    Specifies the value of a vec3 uniform variable for the current program object.

  - ### set3fv

    public void set3fv(int u, int count, long value)
    Specifies the value of a single vec3 uniform variable or a vec3 uniform variable array for the current program object.
    Parameters:
      `count` - the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array
      `value` - a pointer to an array of `count` values that will be used to update the specified uniform variable

  - ### set3fv

    public void set3fv(int u, int offset, int count, float[] value)
    Array version of `set3fv(int, int, long)`.
    Parameters:
      `offset` - the start index in the array

  - ### set4i

    public void set4i(int u, int v0, int v1, int v2, int v3)
    Specifies the value of an ivec4, uvec4 or bvec4 uniform variable for the current program object.

  - ### set4iv

    public void set4iv(int u, int count, long value)
    Specifies the value of a single ivec4, uvec4 or bvec4 uniform variable or an ivec4, uvec4 or bvec4 uniform variable array for the current program object.
    Parameters:
      `count` - the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array
      `value` - a pointer to an array of `count` values that will be used to update the specified uniform variable

  - ### set4iv

    public void set4iv(int u, int offset, int count, int[] value)
    Array version of `set4iv(int, int, long)`.
    Parameters:
      `offset` - the start index in the array

  - ### set4f

    public void set4f(int u, float v0, float v1, float v2, float v3)
    Specifies the value of a vec4 uniform variable for the current program object.

  - ### set4fv

    public void set4fv(int u, int count, long value)
    Specifies the value of a single vec4 uniform variable or a vec4 uniform variable array for the current program object.
    Parameters:
      `count` - the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array
      `value` - a pointer to an array of `count` values that will be used to update the specified uniform variable

  - ### set4fv

    public void set4fv(int u, int offset, int count, float[] value)
    Array version of `set4fv(int, int, long)`.
    Parameters:
      `offset` - the start index in the array

  - ### setMatrix2fv

    public void setMatrix2fv(int u, int count, long value)
    Specifies the value of a single mat2 uniform variable or a mat2 uniform variable array for the current program object. Matrices are column-major.
    Parameters:
      `count` - the number of matrices that are to be modified. This should be 1 if the targeted uniform variable is not an array of matrices, and 1 or more if it is an array of matrices.
      `value` - a pointer to an array of `count` values that will be used to update the specified uniform variable

  - ### setMatrix2fv

    public void setMatrix2fv(int u, int offset, int count, float[] value)
    Array version of `setMatrix2fv(int, int, long)`.
    Parameters:
      `offset` - the start index in the array

  - ### setMatrix3fv

    public void setMatrix3fv(int u, int count, long value)
    Specifies the value of a single mat3 uniform variable or a mat3 uniform variable array for the current program object. Matrices are column-major.
    Parameters:
      `count` - the number of matrices that are to be modified. This should be 1 if the targeted uniform variable is not an array of matrices, and 1 or more if it is an array of matrices.
      `value` - a pointer to an array of `count` values that will be used to update the specified uniform variable

  - ### setMatrix3fv

    public void setMatrix3fv(int u, int offset, int count, float[] value)
    Array version of `setMatrix3fv(int, int, long)`.
    Parameters:
      `offset` - the start index in the array

  - ### setMatrix4fv

    public void setMatrix4fv(int u, int count, long value)
    Specifies the value of a single mat4 uniform variable or a mat4 uniform variable array for the current program object. Matrices are column-major.
    Parameters:
      `count` - the number of matrices that are to be modified. This should be 1 if the targeted uniform variable is not an array of matrices, and 1 or more if it is an array of matrices.
      `value` - a pointer to an array of `count` values that will be used to update the specified uniform variable

  - ### setMatrix4fv

    public void setMatrix4fv(int u, int offset, int count, float[] value)
    Array version of `setMatrix4fv(int, int, long)`.
    Parameters:
      `offset` - the start index in the array

  - ### setMatrix3f

    public void setMatrix3f(int u, Matrixc matrix)
    Convenience method for uploading a Matrix to a 3x3 matrix uniform.

  - ### setMatrix3f

    public void setMatrix3f(int u, Matrix3 matrix)
    Convenience method for uploading a Matrix to a 3x3 matrix uniform.

  - ### setMatrix4f

    public void setMatrix4f(int u, Matrix4 matrix)
    Convenience method for uploading a Matrix4 to a 4x4 matrix uniform.

  - ### getBufferPtrAndMarkDirty

    protected long getBufferPtrAndMarkDirty(int uni)