fix some crashes in metal implementation when pathCount and etlCount are 0
This commit is contained in:
parent
d3e27df818
commit
b9e843f4bb
|
@ -984,6 +984,8 @@ 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];
|
||||||
|
@ -1004,15 +1006,18 @@ void oc_mtl_render_batch(oc_mtl_canvas_backend* backend,
|
||||||
|
|
||||||
[pathEncoder dispatchThreads:pathGridSize threadsPerThreadgroup:pathGroupSize];
|
[pathEncoder dispatchThreads:pathGridSize threadsPerThreadgroup:pathGroupSize];
|
||||||
[pathEncoder endEncoding];
|
[pathEncoder endEncoding];
|
||||||
|
}
|
||||||
//NOTE: segment setup pass
|
|
||||||
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 tileOpMax = [backend->tileOpBuffer length] / sizeof(oc_mtl_tile_op);
|
||||||
int segmentMax = [backend->segmentBuffer length] / sizeof(oc_mtl_segment);
|
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];
|
||||||
|
|
||||||
[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];
|
||||||
|
@ -1033,8 +1038,11 @@ 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];
|
||||||
|
@ -1049,8 +1057,11 @@ 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];
|
||||||
|
@ -1074,6 +1085,7 @@ 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