|
|
|
|
|
|
|
|
|
|
public const int COMPUTE_BUFFER_MAX_ITEM_NUM = 1024 * 1024; // maxsize = 1M vertex/index
|
|
|
|
|
|
|
|
static void tryReleaseComputeBuffer() { |
|
|
|
static void _releaseComputeBuffer() { |
|
|
|
if (!CanvasShader.supportComputeBuffer) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
_indexBuffer = null; |
|
|
|
} |
|
|
|
|
|
|
|
void initComputeBuffer() { |
|
|
|
void _initComputeBuffer() { |
|
|
|
var stride = Marshal.SizeOf(typeof(uiVertex)); |
|
|
|
var strideIndex = Marshal.SizeOf(typeof(int)); |
|
|
|
_computeBuffer = new ComputeBuffer(COMPUTE_BUFFER_MAX_ITEM_NUM, stride); |
|
|
|
|
|
|
_indices = new List<int>(); |
|
|
|
} |
|
|
|
|
|
|
|
void resetComputeBuffer() { |
|
|
|
void _resetComputeBuffer() { |
|
|
|
this.initComputeBuffer(); |
|
|
|
this._initComputeBuffer(); |
|
|
|
} |
|
|
|
|
|
|
|
_vertices.Clear(); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void bindComputeBuffer() { |
|
|
|
void _bindComputeBuffer() { |
|
|
|
if (!CanvasShader.supportComputeBuffer) return; |
|
|
|
|
|
|
|
_computeBuffer.SetData(_vertices); |
|
|
|
|
|
|
void addMeshToComputeBuffer(List<Vector3> vertex, List<Vector2> uv, List<int> triangles) { |
|
|
|
void _addMeshToComputeBuffer(List<Vector3> vertex, List<Vector2> uv, List<int> triangles) { |
|
|
|
if (!CanvasShader.supportComputeBuffer) return; |
|
|
|
|
|
|
|
_startVertex = _vertices.Count; |
|
|
|