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
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:
-
Field Summary
Modifier and TypeFieldDescriptionprotected final long
protected final int[]
protected boolean
protected final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
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 ofset1fv(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 ofset1iv(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 ofset2fv(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 ofset2iv(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 ofset3fv(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 ofset3iv(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 ofset4fv(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 ofset4iv(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 ofsetMatrix2fv(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 ofsetMatrix3fv(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 ofsetMatrix4fv(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.
-
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 uniformsuniformSize
- 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 classRefCnt
-
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 arrayvalue
- a pointer to an array ofcount
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 ofset1iv(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 arrayvalue
- a pointer to an array ofcount
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 ofset1fv(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 arrayvalue
- a pointer to an array ofcount
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 ofset2iv(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 arrayvalue
- a pointer to an array ofcount
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 ofset2fv(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 arrayvalue
- a pointer to an array ofcount
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 ofset3iv(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 arrayvalue
- a pointer to an array ofcount
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 ofset3fv(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 arrayvalue
- a pointer to an array ofcount
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 ofset4iv(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 arrayvalue
- a pointer to an array ofcount
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 ofset4fv(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 ofcount
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 ofsetMatrix2fv(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 ofcount
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 ofsetMatrix3fv(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 ofcount
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 ofsetMatrix4fv(int, int, long)
.- Parameters:
offset
- the start index in the array
-
setMatrix3f
Convenience method for uploading a Matrix to a 3x3 matrix uniform. -
setMatrix3f
Convenience method for uploading a Matrix to a 3x3 matrix uniform. -
setMatrix4f
Convenience method for uploading a Matrix4 to a 4x4 matrix uniform. -
getBufferPtrAndMarkDirty
protected long getBufferPtrAndMarkDirty(int uni)
-