[osx canvas] Early out when eltCount or pathCount == 0, which avoid encoding empty passes and firing metal asserts when running in debug mode from xcode.
This commit is contained in:
parent
4b1ab4db97
commit
ceb4a3a95d
|
@ -952,6 +952,11 @@ void oc_mtl_render_batch(oc_mtl_canvas_backend* backend,
|
||||||
int pathCount = backend->pathCount - backend->pathBatchStart;
|
int pathCount = backend->pathCount - backend->pathBatchStart;
|
||||||
int eltCount = backend->eltCount - backend->eltBatchStart;
|
int eltCount = backend->eltCount - backend->eltBatchStart;
|
||||||
|
|
||||||
|
if(!pathCount || !eltCount)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//NOTE: update intermediate buffers sizes if needed
|
//NOTE: update intermediate buffers sizes if needed
|
||||||
|
|
||||||
oc_mtl_grow_buffer_if_needed(backend, &backend->pathQueueBuffer, pathCount * sizeof(oc_mtl_path_queue));
|
oc_mtl_grow_buffer_if_needed(backend, &backend->pathQueueBuffer, pathCount * sizeof(oc_mtl_path_queue));
|
||||||
|
@ -984,8 +989,6 @@ void oc_mtl_render_batch(oc_mtl_canvas_backend* backend,
|
||||||
[blitEncoder endEncoding];
|
[blitEncoder endEncoding];
|
||||||
|
|
||||||
//NOTE: path setup pass
|
//NOTE: path setup pass
|
||||||
if(pathCount > 0)
|
|
||||||
{
|
|
||||||
id<MTLComputeCommandEncoder> pathEncoder = [surface->commandBuffer computeCommandEncoder];
|
id<MTLComputeCommandEncoder> pathEncoder = [surface->commandBuffer computeCommandEncoder];
|
||||||
pathEncoder.label = @"path pass";
|
pathEncoder.label = @"path pass";
|
||||||
[pathEncoder setComputePipelineState:backend->pathPipeline];
|
[pathEncoder setComputePipelineState:backend->pathPipeline];
|
||||||
|
@ -1006,18 +1009,15 @@ void oc_mtl_render_batch(oc_mtl_canvas_backend* backend,
|
||||||
|
|
||||||
[pathEncoder dispatchThreads:pathGridSize threadsPerThreadgroup:pathGroupSize];
|
[pathEncoder dispatchThreads:pathGridSize threadsPerThreadgroup:pathGroupSize];
|
||||||
[pathEncoder endEncoding];
|
[pathEncoder endEncoding];
|
||||||
}
|
|
||||||
|
|
||||||
int tileOpMax = [backend->tileOpBuffer length] / sizeof(oc_mtl_tile_op);
|
|
||||||
int segmentMax = [backend->segmentBuffer length] / sizeof(oc_mtl_segment);
|
|
||||||
|
|
||||||
//NOTE: segment setup pass
|
//NOTE: segment setup pass
|
||||||
if(eltCount > 0)
|
|
||||||
{
|
|
||||||
id<MTLComputeCommandEncoder> segmentEncoder = [surface->commandBuffer computeCommandEncoder];
|
id<MTLComputeCommandEncoder> segmentEncoder = [surface->commandBuffer computeCommandEncoder];
|
||||||
segmentEncoder.label = @"segment pass";
|
segmentEncoder.label = @"segment pass";
|
||||||
[segmentEncoder setComputePipelineState:backend->segmentPipeline];
|
[segmentEncoder setComputePipelineState:backend->segmentPipeline];
|
||||||
|
|
||||||
|
int tileOpMax = [backend->tileOpBuffer length] / sizeof(oc_mtl_tile_op);
|
||||||
|
int segmentMax = [backend->segmentBuffer length] / sizeof(oc_mtl_segment);
|
||||||
|
|
||||||
[segmentEncoder setBytes:&eltCount length:sizeof(int) atIndex:0];
|
[segmentEncoder setBytes:&eltCount length:sizeof(int) atIndex:0];
|
||||||
[segmentEncoder setBuffer:backend->elementBuffer[backend->bufferIndex] offset:elementBufferOffset atIndex:1];
|
[segmentEncoder setBuffer:backend->elementBuffer[backend->bufferIndex] offset:elementBufferOffset atIndex:1];
|
||||||
[segmentEncoder setBuffer:backend->segmentCountBuffer offset:0 atIndex:2];
|
[segmentEncoder setBuffer:backend->segmentCountBuffer offset:0 atIndex:2];
|
||||||
|
@ -1038,11 +1038,8 @@ void oc_mtl_render_batch(oc_mtl_canvas_backend* backend,
|
||||||
|
|
||||||
[segmentEncoder dispatchThreads:segmentGridSize threadsPerThreadgroup:segmentGroupSize];
|
[segmentEncoder dispatchThreads:segmentGridSize threadsPerThreadgroup:segmentGroupSize];
|
||||||
[segmentEncoder endEncoding];
|
[segmentEncoder endEncoding];
|
||||||
}
|
|
||||||
|
|
||||||
//NOTE: backprop pass
|
//NOTE: backprop pass
|
||||||
if(pathCount > 0)
|
|
||||||
{
|
|
||||||
id<MTLComputeCommandEncoder> backpropEncoder = [surface->commandBuffer computeCommandEncoder];
|
id<MTLComputeCommandEncoder> backpropEncoder = [surface->commandBuffer computeCommandEncoder];
|
||||||
backpropEncoder.label = @"backprop pass";
|
backpropEncoder.label = @"backprop pass";
|
||||||
[backpropEncoder setComputePipelineState:backend->backpropPipeline];
|
[backpropEncoder setComputePipelineState:backend->backpropPipeline];
|
||||||
|
@ -1057,11 +1054,8 @@ void oc_mtl_render_batch(oc_mtl_canvas_backend* backend,
|
||||||
|
|
||||||
[backpropEncoder dispatchThreads:backpropGridSize threadsPerThreadgroup:backpropGroupSize];
|
[backpropEncoder dispatchThreads:backpropGridSize threadsPerThreadgroup:backpropGroupSize];
|
||||||
[backpropEncoder endEncoding];
|
[backpropEncoder endEncoding];
|
||||||
}
|
|
||||||
|
|
||||||
//NOTE: merge pass
|
//NOTE: merge pass
|
||||||
if(pathCount > 0)
|
|
||||||
{
|
|
||||||
id<MTLComputeCommandEncoder> mergeEncoder = [surface->commandBuffer computeCommandEncoder];
|
id<MTLComputeCommandEncoder> mergeEncoder = [surface->commandBuffer computeCommandEncoder];
|
||||||
mergeEncoder.label = @"merge pass";
|
mergeEncoder.label = @"merge pass";
|
||||||
[mergeEncoder setComputePipelineState:backend->mergePipeline];
|
[mergeEncoder setComputePipelineState:backend->mergePipeline];
|
||||||
|
@ -1085,7 +1079,6 @@ void oc_mtl_render_batch(oc_mtl_canvas_backend* backend,
|
||||||
|
|
||||||
[mergeEncoder dispatchThreads:mergeGridSize threadsPerThreadgroup:mergeGroupSize];
|
[mergeEncoder dispatchThreads:mergeGridSize threadsPerThreadgroup:mergeGroupSize];
|
||||||
[mergeEncoder endEncoding];
|
[mergeEncoder endEncoding];
|
||||||
}
|
|
||||||
|
|
||||||
//NOTE: raster pass
|
//NOTE: raster pass
|
||||||
id<MTLComputeCommandEncoder> rasterEncoder = [surface->commandBuffer computeCommandEncoder];
|
id<MTLComputeCommandEncoder> rasterEncoder = [surface->commandBuffer computeCommandEncoder];
|
||||||
|
|
Loading…
Reference in New Issue