Merge pull request #810 from billhollings/master

Track performance of CAMetalLayer nextDrawable call.
This commit is contained in:
Bill Hollings 2020-01-06 10:19:52 -05:00 committed by GitHub
commit 8595f24508
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 11 deletions

View File

@ -22,6 +22,7 @@ Released TBD
- Fix crash when app does not use queue family zero. - Fix crash when app does not use queue family zero.
- Fix buffer offset in `vkCmdPushDescriptorSet()` for non-dedicated buffer memory. - Fix buffer offset in `vkCmdPushDescriptorSet()` for non-dedicated buffer memory.
- Fix Metal validation error on push constant sizing differences between C and MSL structs. - Fix Metal validation error on push constant sizing differences between C and MSL structs.
- Track performance of `CAMetalLayer nextDrawable` call.
- Update `VK_MVK_MOLTENVK_SPEC_VERSION` to `24`. - Update `VK_MVK_MOLTENVK_SPEC_VERSION` to `24`.

View File

@ -608,7 +608,6 @@ typedef struct {
MVKPerformanceTracker glslToSPRIV; /** Convert GLSL to SPIR-V code. */ MVKPerformanceTracker glslToSPRIV; /** Convert GLSL to SPIR-V code. */
} MVKShaderCompilationPerformance; } MVKShaderCompilationPerformance;
/** MoltenVK performance of pipeline cache activities. */ /** MoltenVK performance of pipeline cache activities. */
typedef struct { typedef struct {
MVKPerformanceTracker sizePipelineCache; /** Calculate the size of cache data required to write MSL to pipeline cache data stream. */ MVKPerformanceTracker sizePipelineCache; /** Calculate the size of cache data required to write MSL to pipeline cache data stream. */
@ -620,6 +619,7 @@ typedef struct {
typedef struct { typedef struct {
MVKPerformanceTracker mtlQueueAccess; /** Create an MTLCommmandQueue or access an existing cached instance. */ MVKPerformanceTracker mtlQueueAccess; /** Create an MTLCommmandQueue or access an existing cached instance. */
MVKPerformanceTracker mtlCommandBufferCompletion; /** Completion of a MTLCommandBuffer on the GPU, from commit to completion callback. */ MVKPerformanceTracker mtlCommandBufferCompletion; /** Completion of a MTLCommandBuffer on the GPU, from commit to completion callback. */
MVKPerformanceTracker nextCAMetalDrawable; /** Retrieve next CAMetalDrawable from CAMetalLayer during presentation. */
} MVKQueuePerformance; } MVKQueuePerformance;
/** /**

View File

@ -2493,6 +2493,7 @@ const char* MVKDevice::getActivityPerformanceDescription(MVKPerformanceTracker&
if (&activityTracker == &_performanceStatistics.pipelineCache.readPipelineCache) { return "read MSL from pipeline cache"; } if (&activityTracker == &_performanceStatistics.pipelineCache.readPipelineCache) { return "read MSL from pipeline cache"; }
if (&activityTracker == &_performanceStatistics.queue.mtlQueueAccess) { return "access MTLCommandQueue"; } if (&activityTracker == &_performanceStatistics.queue.mtlQueueAccess) { return "access MTLCommandQueue"; }
if (&activityTracker == &_performanceStatistics.queue.mtlCommandBufferCompletion) { return "complete MTLCommandBuffer"; } if (&activityTracker == &_performanceStatistics.queue.mtlCommandBufferCompletion) { return "complete MTLCommandBuffer"; }
if (&activityTracker == &_performanceStatistics.queue.nextCAMetalDrawable) { return "retrieve a CAMetalDrawable from CAMetalLayer"; }
return "Unknown performance activity"; return "Unknown performance activity";
} }
@ -2638,6 +2639,7 @@ void MVKDevice::initPerformanceTracking() {
_performanceStatistics.pipelineCache.readPipelineCache = initPerf; _performanceStatistics.pipelineCache.readPipelineCache = initPerf;
_performanceStatistics.queue.mtlQueueAccess = initPerf; _performanceStatistics.queue.mtlQueueAccess = initPerf;
_performanceStatistics.queue.mtlCommandBufferCompletion = initPerf; _performanceStatistics.queue.mtlCommandBufferCompletion = initPerf;
_performanceStatistics.queue.nextCAMetalDrawable = initPerf;
} }
void MVKDevice::initPhysicalDevice(MVKPhysicalDevice* physicalDevice, const VkDeviceCreateInfo* pCreateInfo) { void MVKDevice::initPhysicalDevice(MVKPhysicalDevice* physicalDevice, const VkDeviceCreateInfo* pCreateInfo) {

View File

@ -269,7 +269,7 @@ void MVKQueueCommandBufferSubmission::commitActiveMTLCommandBuffer(bool signalCo
// otherwise if this instance has no content, it will not finish() and be destroyed. // otherwise if this instance has no content, it will not finish() and be destroyed.
if (signalCompletion || _trackPerformance) { if (signalCompletion || _trackPerformance) {
[getActiveMTLCommandBuffer() addCompletedHandler: ^(id<MTLCommandBuffer> mtlCmdBuff) { [getActiveMTLCommandBuffer() addCompletedHandler: ^(id<MTLCommandBuffer> mtlCmdBuff) {
_queue->_device->addActivityPerformance(mkvDev->_performanceStatistics.queue.mtlCommandBufferCompletion, startTime); mkvDev->addActivityPerformance(mkvDev->_performanceStatistics.queue.mtlCommandBufferCompletion, startTime);
if (signalCompletion) { this->finish(); } if (signalCompletion) { this->finish(); }
}]; }];
} }

View File

@ -346,15 +346,19 @@ void MVKSwapchain::setHDRMetadataEXT(const VkHdrMetadataEXT& metadata) {
#pragma mark Metal #pragma mark Metal
id<CAMetalDrawable> MVKSwapchain::getCAMetalDrawable(uint32_t imageIndex) { id<CAMetalDrawable> MVKSwapchain::getCAMetalDrawable(uint32_t imageIndex) {
if ( _mtlDrawables[imageIndex] ) { return _mtlDrawables[imageIndex]; } id<CAMetalDrawable> nextDrwbl = _mtlDrawables[imageIndex];
@autoreleasepool { // Allow auto-released drawable object to be reclaimed before end of loop while ( !nextDrwbl ) {
id<CAMetalDrawable> nextDrwbl = nil; @autoreleasepool { // Allow auto-released drawable object to be reclaimed before end of loop
while ( !(nextDrwbl = [_mtlLayer nextDrawable]) ) { uint64_t startTime = _device->getPerformanceTimestamp();
MVKLogError("Drawable could not be retrieved! Elapsed time: %.6f ms.", mvkGetElapsedMilliseconds());
} nextDrwbl = _mtlLayer.nextDrawable;
_mtlDrawables[imageIndex] = [nextDrwbl retain]; if ( !nextDrwbl ) { MVKLogError("Drawable could not be retrieved! Elapsed time: %.6f ms.", mvkGetElapsedMilliseconds()); }
} _mtlDrawables[imageIndex] = [nextDrwbl retain];
return _mtlDrawables[imageIndex];
_device->addActivityPerformance(_device->_performanceStatistics.queue.nextCAMetalDrawable, startTime);
}
}
return nextDrwbl;
} }
// Removes and releases a Metal drawable object, so that it can be lazily created by getCAMetalDrawable(). // Removes and releases a Metal drawable object, so that it can be lazily created by getCAMetalDrawable().