[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 eltCount = backend->eltCount - backend->eltBatchStart;
|
||||
|
||||
if(!pathCount || !eltCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//NOTE: update intermediate buffers sizes if needed
|
||||
|
||||
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];
|
||||
|
||||
//NOTE: path setup pass
|
||||
if(pathCount > 0)
|
||||
{
|
||||
id<MTLComputeCommandEncoder> pathEncoder = [surface->commandBuffer computeCommandEncoder];
|
||||
pathEncoder.label = @"path pass";
|
||||
[pathEncoder setComputePipelineState:backend->pathPipeline];
|
||||
|
@ -1006,18 +1009,15 @@ void oc_mtl_render_batch(oc_mtl_canvas_backend* backend,
|
|||
|
||||
[pathEncoder dispatchThreads:pathGridSize threadsPerThreadgroup:pathGroupSize];
|
||||
[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
|
||||
if(eltCount > 0)
|
||||
{
|
||||
id<MTLComputeCommandEncoder> segmentEncoder = [surface->commandBuffer computeCommandEncoder];
|
||||
segmentEncoder.label = @"segment pass";
|
||||
[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 setBuffer:backend->elementBuffer[backend->bufferIndex] offset:elementBufferOffset atIndex:1];
|
||||
[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 endEncoding];
|
||||
}
|
||||
|
||||
//NOTE: backprop pass
|
||||
if(pathCount > 0)
|
||||
{
|
||||
id<MTLComputeCommandEncoder> backpropEncoder = [surface->commandBuffer computeCommandEncoder];
|
||||
backpropEncoder.label = @"backprop pass";
|
||||
[backpropEncoder setComputePipelineState:backend->backpropPipeline];
|
||||
|
@ -1057,11 +1054,8 @@ void oc_mtl_render_batch(oc_mtl_canvas_backend* backend,
|
|||
|
||||
[backpropEncoder dispatchThreads:backpropGridSize threadsPerThreadgroup:backpropGroupSize];
|
||||
[backpropEncoder endEncoding];
|
||||
}
|
||||
|
||||
//NOTE: merge pass
|
||||
if(pathCount > 0)
|
||||
{
|
||||
id<MTLComputeCommandEncoder> mergeEncoder = [surface->commandBuffer computeCommandEncoder];
|
||||
mergeEncoder.label = @"merge pass";
|
||||
[mergeEncoder setComputePipelineState:backend->mergePipeline];
|
||||
|
@ -1085,7 +1079,6 @@ void oc_mtl_render_batch(oc_mtl_canvas_backend* backend,
|
|||
|
||||
[mergeEncoder dispatchThreads:mergeGridSize threadsPerThreadgroup:mergeGroupSize];
|
||||
[mergeEncoder endEncoding];
|
||||
}
|
||||
|
||||
//NOTE: raster pass
|
||||
id<MTLComputeCommandEncoder> rasterEncoder = [surface->commandBuffer computeCommandEncoder];
|
||||
|
|
Loading…
Reference in New Issue