浏览代码

make compute buffer non-static

/main
xingwei.zhu 5 年前
当前提交
707b5754
共有 2 个文件被更改,包括 42 次插入47 次删除
  1. 74
      Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_computebuffer_utils.cs
  2. 15
      Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_impl.cs

74
Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_computebuffer_utils.cs


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);
}
}
}

15
Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_impl.cs


this._lastScissor = null;
this._layers.Clear();
}
_instanceNum--;
_releaseComputeBuffer();
this._releaseComputeBuffer();
}
public PictureFlusher(RenderTexture renderTexture, float devicePixelRatio, MeshPool meshPool) {

this.___drawTextDrawMeshCallback = this._drawTextDrawMeshCallback;
this.___drawPathDrawMeshCallback2 = this._drawPathDrawMeshCallback2;
this.___drawPathDrawMeshCallback = this._drawPathDrawMeshCallback;
_instanceNum++;
}
readonly _drawPathDrawMeshCallbackDelegate ___drawTextDrawMeshCallback;

}
D.assert(mesh.vertices.Count > 0);
if (CanvasShader.supportComputeBuffer) {
if (this.supportComputeBuffer) {
cmd.properties.SetBuffer(CmdDraw.vertexBufferId, _computeBuffer);
cmd.properties.SetBuffer(CmdDraw.indexBufferId, _indexBuffer);
cmd.properties.SetInt(CmdDraw.startIndexId, _startIndex);
cmd.properties.SetBuffer(CmdDraw.vertexBufferId, this._computeBuffer);
cmd.properties.SetBuffer(CmdDraw.indexBufferId, this._indexBuffer);
cmd.properties.SetInt(CmdDraw.startIndexId, this._startIndex);
cmdBuf.DrawProcedural(Matrix4x4.identity, cmd.material, cmd.pass, MeshTopology.Triangles, mesh.triangles.Count, 1, cmd.properties.mpb);
}
else {

正在加载...
取消
保存