Don't use MTLCommandBuffer push/popDebugGroup if not available.

Log use of MTLEvent for semaphores.
This commit is contained in:
Bill Hollings 2019-08-27 11:38:32 -04:00
parent bb3cdd7af4
commit 937813f48e
5 changed files with 30 additions and 4 deletions

View File

@ -40,6 +40,7 @@ Released TBD
- `VkPhysicalDevicePortabilitySubsetFeaturesEXTX::events` set to `true`. - `VkPhysicalDevicePortabilitySubsetFeaturesEXTX::events` set to `true`.
- Always submit surface presentations using `MTLCommandBuffer`. - Always submit surface presentations using `MTLCommandBuffer`.
`MVKConfiguration::presentWithCommandBuffer` is now obsolete. `MVKConfiguration::presentWithCommandBuffer` is now obsolete.
- Don't use `MTLCommandBuffer push/popDebugGroup` if not available.
- Add ability to automatically cause an *Xcode* GPU capture without developer intervention. - Add ability to automatically cause an *Xcode* GPU capture without developer intervention.

View File

@ -95,3 +95,11 @@ void mvkCmdEndDebugUtilsLabel(MVKCommandBuffer* cmdBuff);
void mvkCmdInsertDebugUtilsLabel(MVKCommandBuffer* cmdBuff, const VkDebugUtilsLabelEXT* pLabelInfo); void mvkCmdInsertDebugUtilsLabel(MVKCommandBuffer* cmdBuff, const VkDebugUtilsLabelEXT* pLabelInfo);
#pragma mark -
#pragma mark Support functions
void mvkPushDebugGroup(id<MTLCommandBuffer> mtlCmdBuffer, NSString* name);
void mvkPopDebugGroup(id<MTLCommandBuffer> mtlCmdBuffer);

View File

@ -47,7 +47,7 @@ void MVKCmdDebugMarkerBegin::encode(MVKCommandEncoder* cmdEncoder) {
if (mtlCmdEnc) { if (mtlCmdEnc) {
[mtlCmdEnc pushDebugGroup: _markerName]; [mtlCmdEnc pushDebugGroup: _markerName];
} else { } else {
[cmdEncoder->_mtlCmdBuffer pushDebugGroup: _markerName]; mvkPushDebugGroup(cmdEncoder->_mtlCmdBuffer, _markerName);
} }
} }
@ -65,7 +65,7 @@ void MVKCmdDebugMarkerEnd::encode(MVKCommandEncoder* cmdEncoder) {
if (mtlCmdEnc) { if (mtlCmdEnc) {
[mtlCmdEnc popDebugGroup]; [mtlCmdEnc popDebugGroup];
} else { } else {
[cmdEncoder->_mtlCmdBuffer popDebugGroup]; mvkPopDebugGroup(cmdEncoder->_mtlCmdBuffer);
} }
} }
@ -121,3 +121,18 @@ void mvkCmdInsertDebugUtilsLabel(MVKCommandBuffer* cmdBuff, const VkDebugUtilsLa
cmdBuff->addCommand(cmd); cmdBuff->addCommand(cmd);
} }
#pragma mark -
#pragma mark Support functions
void mvkPushDebugGroup(id<MTLCommandBuffer> mtlCmdBuffer, NSString* name) {
if ([mtlCmdBuffer respondsToSelector: @selector(pushDebugGroup:)]) {
[mtlCmdBuffer pushDebugGroup: name];
}
}
void mvkPopDebugGroup(id<MTLCommandBuffer> mtlCmdBuffer) {
if ([mtlCmdBuffer respondsToSelector: @selector(popDebugGroup)]) {
[mtlCmdBuffer popDebugGroup];
}
}

View File

@ -2359,6 +2359,7 @@ void MVKDevice::initPhysicalDevice(MVKPhysicalDevice* physicalDevice, const VkDe
if (_pMetalFeatures->events) { if (_pMetalFeatures->events) {
MVK_SET_FROM_ENV_OR_BUILD_BOOL(_useMTLEventsForSemaphores, MVK_ALLOW_METAL_EVENTS); MVK_SET_FROM_ENV_OR_BUILD_BOOL(_useMTLEventsForSemaphores, MVK_ALLOW_METAL_EVENTS);
} }
MVKLogInfo("%s MTLEvent for semaphores.", _useMTLEventsForSemaphores ? "Using" : "NOT using");
#if MVK_MACOS #if MVK_MACOS
// If we have selected a high-power GPU and want to force the window system // If we have selected a high-power GPU and want to force the window system

View File

@ -20,6 +20,7 @@
#include "MVKQueue.h" #include "MVKQueue.h"
#include "MVKSwapchain.h" #include "MVKSwapchain.h"
#include "MVKCommandBuffer.h" #include "MVKCommandBuffer.h"
#include "MVKCmdDebug.h"
#include "mvk_datatypes.hpp" #include "mvk_datatypes.hpp"
#include "MVKFoundation.h" #include "MVKFoundation.h"
#include "MVKLogging.h" #include "MVKLogging.h"
@ -1279,9 +1280,9 @@ void MVKSwapchainImage::presentCAMetalDrawable(id<MTLCommandBuffer> mtlCmdBuff)
_swapchain->willPresentSurface(getMTLTexture(), mtlCmdBuff); _swapchain->willPresentSurface(getMTLTexture(), mtlCmdBuff);
NSString* scName = _swapchain->getDebugName(); NSString* scName = _swapchain->getDebugName();
if (scName) { [mtlCmdBuff pushDebugGroup: scName]; } if (scName) { mvkPushDebugGroup(mtlCmdBuff, scName); }
[mtlCmdBuff presentDrawable: getCAMetalDrawable()]; [mtlCmdBuff presentDrawable: getCAMetalDrawable()];
if (scName) { [mtlCmdBuff popDebugGroup]; } if (scName) { mvkPopDebugGroup(mtlCmdBuff); }
resetMetalSurface(); resetMetalSurface();
_swapchain->signalPresentationSemaphore(_swapchainIndex, mtlCmdBuff); _swapchain->signalPresentationSemaphore(_swapchainIndex, mtlCmdBuff);