Merge pull request #1543 from billhollings/fix-gpu-counter-mtlfence-deletion

Fix deletion of GPU counter MTLFence while it is being used by MTLCommandBuffer.
This commit is contained in:
Bill Hollings 2022-03-10 13:51:34 -05:00 committed by GitHub
commit d3b5d113f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 8 deletions

View File

@ -22,6 +22,7 @@ Released TBD
- Support base vertex instance support in shader conversion.
- Fix alignment between outputs and inputs between shader stages when using nested structures.
- Fix issue where the depth component of a stencil-only renderpass attachment was incorrectly attempting to be stored.
- Fix deletion of GPU counter `MTLFence` while it is being used by `MTLCommandBuffer`.
- `MoltenVKShaderConverter` tool defaults to the highest MSL version supported on runtime OS.
- Update *glslang* version, to use `python3` in *glslang* scripts, to replace missing `python` on *macOS 12.3*.
- Update to latest SPIRV-Cross:

View File

@ -29,7 +29,6 @@
#include <unordered_map>
class MVKCommandPool;
class MVKQueue;
class MVKQueueCommandBufferSubmission;
class MVKCommandEncoder;
class MVKCommandEncodingPool;
@ -492,8 +491,6 @@ public:
MVKCommandEncoder(MVKCommandBuffer* cmdBuffer);
~MVKCommandEncoder() override;
protected:
void addActivatedQueries(MVKQueryPool* pQueryPool, uint32_t query, uint32_t queryCount);
void finishQueries();

View File

@ -830,7 +830,14 @@ void MVKCommandEncoder::encodeTimestampStageCounterSamples() {}
#endif
id<MTLFence> MVKCommandEncoder::getStageCountersMTLFence() {
if ( !_stageCountersMTLFence ) { _stageCountersMTLFence = [getMTLDevice() newFence]; } //retained
if ( !_stageCountersMTLFence ) {
// Create MTLFence as local ref and pass to completion handler
// block to release once MTLCommandBuffer no longer needs it.
id<MTLFence> mtlFence = [getMTLDevice() newFence];
[_mtlCmdBuffer addCompletedHandler: ^(id<MTLCommandBuffer> mcb) { [mtlFence release]; }];
_stageCountersMTLFence = mtlFence; // retained
}
return _stageCountersMTLFence;
}
@ -899,10 +906,6 @@ MVKCommandEncoder::MVKCommandEncoder(MVKCommandBuffer* cmdBuffer) : MVKBaseDevic
_stageCountersMTLFence = nil;
}
MVKCommandEncoder::~MVKCommandEncoder() {
[_stageCountersMTLFence release];
}
#pragma mark -
#pragma mark Support functions