Mac m1 fixes (#2150)
* Update the Mac Editor plist application bundle identifier to be different than Lumberyard Fix the editor to have runtime dependencies on the scene modules. Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> * Fix Metal RHI calling unsupported timestamp query api on M1 Macs. Add Query for Timestamps supported on device initialization. Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> * Remove AZ::Scene* runtime dependencies from EmotionFX gem and add AZ::SceneUI as a runtime dependency of SceneProcessing::Editor module. Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>Editor</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.Amazon.Lumberyard.Editor</string>
|
||||
<string>org.O3DE.Editor</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
|
||||
@@ -46,4 +46,8 @@ ly_add_target(
|
||||
AZ::AzCore
|
||||
AZ::AzToolsFramework
|
||||
AZ::AzQtComponents
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AzCore
|
||||
AZ::AzToolsFramework
|
||||
AZ::AzQtComponents
|
||||
)
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace AZ
|
||||
{
|
||||
AZ_UNUSED(device);
|
||||
m_hardwareQueueClass = hardwareQueueClass;
|
||||
m_supportsInterDrawTimestamps = AZ::RHI::QueryTypeFlags::Timestamp == (device->GetFeatures().m_queryTypesMask[static_cast<uint32_t>(hardwareQueueClass)] & AZ::RHI::QueryTypeFlags::Timestamp);
|
||||
}
|
||||
|
||||
void CommandListBase::Reset()
|
||||
@@ -64,7 +65,10 @@ namespace AZ
|
||||
[m_encoder endEncoding];
|
||||
m_encoder = nil;
|
||||
#if AZ_TRAIT_ATOM_METAL_COUNTER_SAMPLING
|
||||
m_timeStampQueue.clear();
|
||||
if (m_supportsInterDrawTimestamps)
|
||||
{
|
||||
m_timeStampQueue.clear();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -144,9 +148,12 @@ namespace AZ
|
||||
m_isEncoded = true;
|
||||
|
||||
#if AZ_TRAIT_ATOM_METAL_COUNTER_SAMPLING
|
||||
for(auto& timeStamp: m_timeStampQueue)
|
||||
if (m_supportsInterDrawTimestamps)
|
||||
{
|
||||
SampleCounters(timeStamp.m_counterSampleBuffer, timeStamp.m_timeStampIndex);
|
||||
for(auto& timeStamp: m_timeStampQueue)
|
||||
{
|
||||
SampleCounters(timeStamp.m_counterSampleBuffer, timeStamp.m_timeStampIndex);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -195,6 +202,11 @@ namespace AZ
|
||||
#if AZ_TRAIT_ATOM_METAL_COUNTER_SAMPLING
|
||||
void CommandListBase::SampleCounters(id<MTLCounterSampleBuffer> counterSampleBuffer, uint32_t sampleIndex)
|
||||
{
|
||||
if (!m_supportsInterDrawTimestamps)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AZ_Assert(sampleIndex >= 0, "Invalid sample index");
|
||||
//useBarrier - Inserting a barrier ensures that encoded work is complete before the GPU samples the hardware counters.
|
||||
//If it is true there is a performance penalty but you will get consistent results
|
||||
@@ -231,6 +243,11 @@ namespace AZ
|
||||
|
||||
void CommandListBase::SamplePassCounters(id<MTLCounterSampleBuffer> counterSampleBuffer, uint32_t sampleIndex)
|
||||
{
|
||||
if (!m_supportsInterDrawTimestamps)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_encoder == nil)
|
||||
{
|
||||
//Queue the query to be activated upon encoder creation. Applies to timestamp queries
|
||||
|
||||
@@ -101,6 +101,8 @@ namespace AZ
|
||||
|
||||
const AZStd::set<id<MTLHeap>>* m_residentHeaps = nullptr;
|
||||
|
||||
bool m_supportsInterDrawTimestamps = AZ_TRAIT_ATOM_METAL_COUNTER_SAMPLING; // iOS/TVOS = false, MacOS = defaults to true
|
||||
|
||||
#if AZ_TRAIT_ATOM_METAL_COUNTER_SAMPLING
|
||||
struct TimeStampData
|
||||
{
|
||||
|
||||
@@ -328,14 +328,28 @@ namespace AZ
|
||||
m_features.m_indirectDrawSupport = false;
|
||||
|
||||
RHI::QueryTypeFlags counterSamplingFlags = RHI::QueryTypeFlags::None;
|
||||
|
||||
#if AZ_TRAIT_ATOM_METAL_COUNTER_SAMPLING
|
||||
counterSamplingFlags |= (RHI::QueryTypeFlags::Timestamp | RHI::QueryTypeFlags::PipelineStatistics);
|
||||
m_features.m_queryTypesMask[static_cast<uint32_t>(RHI::HardwareQueueClass::Copy)] = RHI::QueryTypeFlags::Timestamp;
|
||||
|
||||
bool supportsInterDrawTimestamps = true;
|
||||
#if defined(__IPHONE_14_0) || defined(__MAC_11_0) || defined(__TVOS_14_0)
|
||||
if (@available(macOS 11.0, iOS 14, tvOS 14, *))
|
||||
{
|
||||
supportsInterDrawTimestamps = [m_metalDevice supportsCounterSampling:MTLCounterSamplingPointAtDrawBoundary];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
supportsInterDrawTimestamps = ![m_metalDevice.name containsString:@"Apple"]; // Apple GPU's don't support inter draw timestamps at the M1/A14 generation
|
||||
}
|
||||
|
||||
if (supportsInterDrawTimestamps)
|
||||
{
|
||||
counterSamplingFlags |= (RHI::QueryTypeFlags::Timestamp | RHI::QueryTypeFlags::PipelineStatistics);
|
||||
m_features.m_queryTypesMask[static_cast<uint32_t>(RHI::HardwareQueueClass::Copy)] = RHI::QueryTypeFlags::Timestamp;
|
||||
}
|
||||
|
||||
m_features.m_queryTypesMask[static_cast<uint32_t>(RHI::HardwareQueueClass::Graphics)] = RHI::QueryTypeFlags::Occlusion | counterSamplingFlags;
|
||||
//Compute queue can do gfx work
|
||||
m_features.m_queryTypesMask[static_cast<uint32_t>(RHI::HardwareQueueClass::Compute)] = RHI::QueryTypeFlags::Occlusion |counterSamplingFlags;
|
||||
m_features.m_queryTypesMask[static_cast<uint32_t>(RHI::HardwareQueueClass::Compute)] = RHI::QueryTypeFlags::Occlusion | counterSamplingFlags;
|
||||
m_features.m_occlusionQueryPrecise = true;
|
||||
|
||||
//Values taken from https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
|
||||
|
||||
@@ -61,6 +61,7 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::SceneCore
|
||||
AZ::SceneData
|
||||
AZ::SceneUI
|
||||
)
|
||||
# the SceneProcessing.Editor module above is only used in Builders and Tools.
|
||||
ly_create_alias(NAME SceneProcessing.Builders NAMESPACE Gem TARGETS Gem::SceneProcessing.Editor)
|
||||
|
||||
Reference in New Issue
Block a user