Improved checks for timestamp GPU counter support on older devices.

Check that appropriate GPU counter set is supported on
the device before creating GPU counter sample buffer.
Don't attempt to timestamp using GPU counters unless
a GPU sample counter buffer has been created.
This commit is contained in:
Bill Hollings 2021-09-13 17:20:00 -04:00
parent 0cf396a70f
commit 4ad5930263
4 changed files with 7 additions and 3 deletions

View File

@ -19,6 +19,7 @@ MoltenVK 1.1.6
Released TBD
- Support maximum point primitive size of 511.
- Improved checks for timestamp GPU counter support on older devices.
- Update to latest SPIRV-Cross version:
- Add support for `OpSpecConstantOp` ops `OpQuantizeToF16` and `OpSRem`.

View File

@ -768,8 +768,8 @@ void MVKCommandEncoder::markTimestamp(MVKTimestampQueryPool* pQueryPool, uint32_
}
addActivatedQueries(pQueryPool, query, queryCount);
MVKCounterSamplingFlags sampPts = _device->_pMetalFeatures->counterSamplingPoints;
if (sampPts) {
if (pQueryPool->hasMTLCounterBuffer()) {
MVKCounterSamplingFlags sampPts = _device->_pMetalFeatures->counterSamplingPoints;
for (uint32_t qOfst = 0; qOfst < queryCount; qOfst++) {
if (mvkIsAnyFlagEnabled(sampPts, MVK_COUNTER_SAMPLING_AT_PIPELINE_STAGE)) {
_timestampStageCounterQueries.push_back({ pQueryPool, query + qOfst });

View File

@ -182,6 +182,9 @@ class MVKGPUCounterQueryPool : public MVKQueryPool {
public:
/** Returns whether a MTLCounterBuffer is being used by this query pool. */
bool hasMTLCounterBuffer() { return _mtlCounterBuffer != nil; }
/**
* Returns the MTLCounterBuffer being used by this query pool,
* or returns nil if GPU counters are not supported.

View File

@ -335,7 +335,7 @@ MVKGPUCounterQueryPool::MVKGPUCounterQueryPool(MVKDevice* device, const VkQueryP
void MVKGPUCounterQueryPool::initMTLCounterSampleBuffer(const VkQueryPoolCreateInfo* pCreateInfo,
id<MTLCounterSet> mtlCounterSet,
const char* queryTypeName) {
if ( !_device->_pMetalFeatures->counterSamplingPoints ) { return; }
if ( !mtlCounterSet ) { return; }
@autoreleasepool {
MTLCounterSampleBufferDescriptor* tsDesc = [[[MTLCounterSampleBufferDescriptor alloc] init] autorelease];