|
|
|
|
|
|
public Vector2 uv; |
|
|
|
} |
|
|
|
|
|
|
|
static ComputeBuffer _computeBuffer; |
|
|
|
static List<uiVertex> _vertices; |
|
|
|
ComputeBuffer _computeBuffer; |
|
|
|
List<uiVertex> _vertices; |
|
|
|
static ComputeBuffer _indexBuffer; |
|
|
|
static List<int> _indices; |
|
|
|
ComputeBuffer _indexBuffer; |
|
|
|
List<int> _indices; |
|
|
|
static int _startVertex; |
|
|
|
static int _startIndex; |
|
|
|
|
|
|
|
static int _instanceNum; |
|
|
|
int _startVertex; |
|
|
|
int _startIndex; |
|
|
|
static void _releaseComputeBuffer() { |
|
|
|
if (!CanvasShader.supportComputeBuffer) { |
|
|
|
return; |
|
|
|
} |
|
|
|
bool supportComputeBuffer { |
|
|
|
get { return CanvasShader.supportComputeBuffer; } |
|
|
|
} |
|
|
|
if (_computeBuffer == null) { |
|
|
|
void _releaseComputeBuffer() { |
|
|
|
if (!this.supportComputeBuffer) { |
|
|
|
if (_instanceNum != 0) { |
|
|
|
if (this._computeBuffer == null) { |
|
|
|
_computeBuffer.Dispose(); |
|
|
|
_indexBuffer.Dispose(); |
|
|
|
_vertices = null; |
|
|
|
_indices = null; |
|
|
|
_computeBuffer = null; |
|
|
|
_indexBuffer = null; |
|
|
|
this._computeBuffer.Dispose(); |
|
|
|
this._indexBuffer.Dispose(); |
|
|
|
this._vertices = null; |
|
|
|
this._indices = null; |
|
|
|
this._computeBuffer = null; |
|
|
|
this._indexBuffer = null; |
|
|
|
_computeBuffer = new ComputeBuffer(COMPUTE_BUFFER_MAX_ITEM_NUM, stride); |
|
|
|
_vertices = new List<uiVertex>(); |
|
|
|
this._computeBuffer = new ComputeBuffer(COMPUTE_BUFFER_MAX_ITEM_NUM, stride); |
|
|
|
this._vertices = new List<uiVertex>(); |
|
|
|
_indexBuffer = new ComputeBuffer(COMPUTE_BUFFER_MAX_ITEM_NUM, strideIndex); |
|
|
|
_indices = new List<int>(); |
|
|
|
this._indexBuffer = new ComputeBuffer(COMPUTE_BUFFER_MAX_ITEM_NUM, strideIndex); |
|
|
|
this._indices = new List<int>(); |
|
|
|
if (!CanvasShader.supportComputeBuffer) return; |
|
|
|
if (!this.supportComputeBuffer) return; |
|
|
|
if (_computeBuffer == null) { |
|
|
|
if (this._computeBuffer == null) { |
|
|
|
_vertices.Clear(); |
|
|
|
_indices.Clear(); |
|
|
|
_startVertex = 0; |
|
|
|
_startIndex = 0; |
|
|
|
this._vertices.Clear(); |
|
|
|
this._indices.Clear(); |
|
|
|
this._startVertex = 0; |
|
|
|
this._startIndex = 0; |
|
|
|
if (!CanvasShader.supportComputeBuffer) return; |
|
|
|
if (!this.supportComputeBuffer) return; |
|
|
|
_computeBuffer.SetData(_vertices); |
|
|
|
_indexBuffer.SetData(_indices); |
|
|
|
this._computeBuffer.SetData(this._vertices); |
|
|
|
this._indexBuffer.SetData(this._indices); |
|
|
|
if (!CanvasShader.supportComputeBuffer) return; |
|
|
|
if (!this.supportComputeBuffer) return; |
|
|
|
_startVertex = _vertices.Count; |
|
|
|
_startIndex = _indices.Count; |
|
|
|
this._startVertex = this._vertices.Count; |
|
|
|
this._startIndex = this._indices.Count; |
|
|
|
_vertices.Add(new uiVertex { |
|
|
|
this._vertices.Add(new uiVertex { |
|
|
|
position = new Vector2(vertex[i].x, vertex[i].y), |
|
|
|
uv = hasUv ? uv[i] : Vector2.zero |
|
|
|
}); |
|
|
|
|
|
|
_indices.Add(triangleId + _startVertex); |
|
|
|
this._indices.Add(triangleId + this._startVertex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |