Merge branch 'stabilization/2106' of https://github.com/o3de/o3de into carlitosan/thecleansing

This commit is contained in:
chcurran
2021-07-07 17:10:27 -07:00
14 changed files with 144 additions and 83 deletions
@@ -142,6 +142,8 @@ namespace AZ
void RayTracingPipelineState::Shutdown()
{
ShutdownInternal();
DeviceObject::Shutdown();
}
}
}
@@ -67,7 +67,8 @@ namespace AZ
void ConstructMeshList(const ModelAsset* model, const AZ::Transform& matParent);
static const int s_MinimumVertexSizeInLeafNode = 3 * 10;
// Stop splitting the tree if more than 10% of the triangles are straddling the split axis
static constexpr float s_MaximumSplitAxisStraddlingTriangles = 1.1;
AZStd::unique_ptr<ModelKdTreeNode> m_pRootNode;
struct MeshData
@@ -84,7 +84,11 @@ namespace AZ
// If either the top or bottom contain all the input indices, the triangles are too close to cut any
// further and the split failed
return indices.size() != outInfo.m_aboveIndices.size() && indices.size() != outInfo.m_belowIndices.size();
// Additionally, if too many triangles straddle the split-axis,
// the triangles are too close and the split failed
// [ATOM-15944] - Use a more sophisticated method to terminate KdTree generation
return indices.size() != outInfo.m_aboveIndices.size() && indices.size() != outInfo.m_belowIndices.size()
&& aznumeric_cast<float>(outInfo.m_aboveIndices.size() + outInfo.m_belowIndices.size()) / aznumeric_cast<float>(indices.size()) < s_MaximumSplitAxisStraddlingTriangles;
}
bool ModelKdTree::Build(const ModelAsset* model)
@@ -16,6 +16,7 @@
#include <AzCore/std/containers/map.h>
#include <AzCore/std/smart_ptr/weak_ptr.h>
#include <AzCore/std/parallel/shared_mutex.h>
#include <AzCore/Asset/AssetCommon.h>
#include <map>
#include <AzFramework/Font/FontInterface.h>
@@ -38,6 +39,7 @@ namespace AZ
class AtomFont
: public ICryFont
, public AzFramework::FontQueryInterface
, private Data::AssetBus::Handler
{
friend class FFont;
@@ -122,6 +124,9 @@ namespace AZ
//! \param outputFullPath Full path to loaded font family, may need resolving with PathUtil::MakeGamePath.
XmlNodeRef LoadFontFamilyXml(const char* fontFamilyName, string& outputDirectory, string& outputFullPath);
// Data::AssetBus::Handler overrides...
void OnAssetReady(Data::Asset<Data::AssetData> asset) override;
private:
AzFramework::ISceneSystem::SceneEvent::Handler m_sceneEventHandler;
@@ -29,6 +29,7 @@
#include <Atom/RPI.Public/RPIUtils.h>
#include <Atom/RPI.Public/DynamicDraw/DynamicDrawInterface.h>
#include <Atom/RPI.Reflect/Asset/AssetUtils.h>
// Static member definitions
const AZ::AtomFont::GlyphSize AZ::AtomFont::defaultGlyphSize = AZ::AtomFont::GlyphSize(ICryFont::defaultGlyphSizeX, ICryFont::defaultGlyphSizeY);
@@ -349,30 +350,18 @@ AZ::AtomFont::AtomFont(ISystem* system)
#endif
AZ::Interface<AzFramework::FontQueryInterface>::Register(this);
// register font per viewport dynamic draw context.
// Queue a load for the font per viewport dynamic draw context shader, and wait for it to load
static const char* shaderFilepath = "Shaders/SimpleTextured.azshader";
AZ::AtomBridge::PerViewportDynamicDraw::Get()->RegisterDynamicDrawContext(
AZ::Name(AZ::AtomFontDynamicDrawContextName),
[](RPI::Ptr<RPI::DynamicDrawContext> drawContext)
{
Data::Instance<RPI::Shader> shader = AZ::RPI::LoadShader(shaderFilepath);
AZ::RPI::ShaderOptionList shaderOptions;
shaderOptions.push_back(AZ::RPI::ShaderOption(AZ::Name("o_useColorChannels"), AZ::Name("false")));
shaderOptions.push_back(AZ::RPI::ShaderOption(AZ::Name("o_clamp"), AZ::Name("true")));
drawContext->InitShaderWithVariant(shader, &shaderOptions);
drawContext->InitVertexFormat(
{
{"POSITION", RHI::Format::R32G32B32_FLOAT},
{"COLOR", RHI::Format::B8G8R8A8_UNORM},
{"TEXCOORD0", RHI::Format::R32G32_FLOAT}
});
drawContext->EndInit();
});
Data::Asset<RPI::ShaderAsset> shaderAsset = RPI::AssetUtils::GetAssetByProductPath<RPI::ShaderAsset>(shaderFilepath, RPI::AssetUtils::TraceLevel::Assert);
shaderAsset.QueueLoad();
Data::AssetBus::Handler::BusConnect(shaderAsset.GetId());
}
AZ::AtomFont::~AtomFont()
{
Data::AssetBus::Handler::BusDisconnect();
AZ::Interface<AzFramework::FontQueryInterface>::Unregister(this);
m_defaultFontDrawInterface = nullptr;
@@ -864,5 +853,36 @@ XmlNodeRef AZ::AtomFont::LoadFontFamilyXml(const char* fontFamilyName, string& o
return root;
}
void AZ::AtomFont::OnAssetReady(Data::Asset<Data::AssetData> asset)
{
Data::Asset<RPI::ShaderAsset> shaderAsset = asset;
AZ::AtomBridge::PerViewportDynamicDraw::Get()->RegisterDynamicDrawContext(
AZ::Name(AZ::AtomFontDynamicDrawContextName),
[shaderAsset](RPI::Ptr<RPI::DynamicDrawContext> drawContext)
{
AZ_Assert(shaderAsset->IsReady(), "Attempting to register the AtomFont"
" dynamic draw context before the shader asset is loaded. The shader should be loaded first"
" to avoid a blocking asset load and potential deadlock, since the DynamicDrawContext lambda"
" will be executed during scene processing and there may be multiple scenes executing in parallel.");
Data::Instance<RPI::Shader> shader = RPI::Shader::FindOrCreate(shaderAsset);
AZ::RPI::ShaderOptionList shaderOptions;
shaderOptions.push_back(AZ::RPI::ShaderOption(AZ::Name("o_useColorChannels"), AZ::Name("false")));
shaderOptions.push_back(AZ::RPI::ShaderOption(AZ::Name("o_clamp"), AZ::Name("true")));
drawContext->InitShaderWithVariant(shader, &shaderOptions);
drawContext->InitVertexFormat(
{
{"POSITION", RHI::Format::R32G32B32_FLOAT},
{"COLOR", RHI::Format::B8G8R8A8_UNORM},
{"TEXCOORD0", RHI::Format::R32G32_FLOAT}
});
drawContext->EndInit();
});
Data::AssetBus::Handler::BusDisconnect();
}
#endif
@@ -27,6 +27,7 @@
#include <Atom/RPI.Public/Image/ImageSystemInterface.h>
#include <Atom/RPI.Reflect/Image/StreamingImageAssetCreator.h>
#include <Atom/RPI.Reflect/Image/ImageMipChainAssetCreator.h>
#include <Atom/RPI.Reflect/Asset/AssetUtils.h>
#include <Atom/RPI.Public/Image/StreamingImagePool.h>
#include <AtomBridge/PerViewportDynamicDrawInterface.h>
@@ -87,6 +88,7 @@ namespace AZ::Render
void AtomViewportDisplayIconsSystemComponent::Deactivate()
{
Data::AssetBus::Handler::BusDisconnect();
Bootstrap::NotificationBus::Handler::BusDisconnect();
auto perViewportDynamicDrawInterface = AtomBridge::PerViewportDynamicDraw::Get();
@@ -338,15 +340,32 @@ namespace AZ::Render
void AtomViewportDisplayIconsSystemComponent::OnBootstrapSceneReady([[maybe_unused]]AZ::RPI::Scene* bootstrapScene)
{
AtomBridge::PerViewportDynamicDraw::Get()->RegisterDynamicDrawContext(m_drawContextName, [](RPI::Ptr<RPI::DynamicDrawContext> drawContext)
{
auto shader = RPI::LoadShader(DrawContextShaderPath);
drawContext->InitShader(shader);
drawContext->InitVertexFormat(
{{"POSITION", RHI::Format::R32G32B32_FLOAT},
{"COLOR", RHI::Format::R8G8B8A8_UNORM},
{"TEXCOORD", RHI::Format::R32G32_FLOAT}});
drawContext->EndInit();
});
// Queue a load for the draw context shader, and wait for it to load
Data::Asset<RPI::ShaderAsset> shaderAsset = RPI::AssetUtils::GetAssetByProductPath<RPI::ShaderAsset>(DrawContextShaderPath, RPI::AssetUtils::TraceLevel::Assert);
shaderAsset.QueueLoad();
Data::AssetBus::Handler::BusConnect(shaderAsset.GetId());
}
void AtomViewportDisplayIconsSystemComponent::OnAssetReady(Data::Asset<Data::AssetData> asset)
{
// Once the shader is loaded, register it with the dynamic draw context
Data::Asset<RPI::ShaderAsset> shaderAsset = asset;
AtomBridge::PerViewportDynamicDraw::Get()->RegisterDynamicDrawContext(m_drawContextName, [shaderAsset](RPI::Ptr<RPI::DynamicDrawContext> drawContext)
{
AZ_Assert(shaderAsset->IsReady(), "Attempting to register the AtomViewportDisplayIconsSystemComponent"
" dynamic draw context before the shader asset is loaded. The shader should be loaded first"
" to avoid a blocking asset load and potential deadlock, since the DynamicDrawContext lambda"
" will be executed during scene processing and there may be multiple scenes executing in parallel.");
Data::Instance<RPI::Shader> shader = RPI::Shader::FindOrCreate(shaderAsset);
drawContext->InitShader(shader);
drawContext->InitVertexFormat(
{ {"POSITION", RHI::Format::R32G32B32_FLOAT},
{"COLOR", RHI::Format::R8G8B8A8_UNORM},
{"TEXCOORD", RHI::Format::R32G32_FLOAT} });
drawContext->EndInit();
});
Data::AssetBus::Handler::BusDisconnect();
}
} // namespace AZ::Render
@@ -27,6 +27,7 @@ namespace AZ
: public AZ::Component
, public AzToolsFramework::EditorViewportIconDisplayInterface
, public AZ::Render::Bootstrap::NotificationBus::Handler
, private Data::AssetBus::Handler
{
public:
AZ_COMPONENT(AtomViewportDisplayIconsSystemComponent, "{AEC1D3E1-1D9A-437A-B4C6-CFAEE620C160}");
@@ -51,6 +52,9 @@ namespace AZ
// AZ::Render::Bootstrap::NotificationBus::Handler overrides...
void OnBootstrapSceneReady(AZ::RPI::Scene* bootstrapScene) override;
// Data::AssetBus::Handler overrides...
void OnAssetReady(Data::Asset<Data::AssetData> asset) override;
private:
static constexpr const char* DrawContextShaderPath = "Shaders/TexturedIcon.azshader";
static constexpr QSize MinimumRenderedSvgSize = QSize(128, 128);
@@ -130,6 +130,12 @@ namespace AZ
arguments.append(QString("--rhi=%1").arg(apiName.GetCStr()));
}
AZ::IO::FixedMaxPathString projectPath(AZ::Utils::GetProjectPath());
if (!projectPath.empty())
{
arguments.append(QString("--project-path=%1").arg(projectPath.c_str()));
}
AtomToolsFramework::LaunchTool("MaterialEditor", ".exe", arguments);
}
+1 -1
View File
@@ -8,7 +8,7 @@
#include <AzCore/Math/Vector3.h>
#include <IRenderAuxGeom.h>
#include <Azcore/Math/Color.h>
#include <AzCore/Math/Color.h>
namespace Blast
{
@@ -8,7 +8,7 @@
#include <Atom/Feature/Mesh/MeshFeatureProcessorInterface.h>
#include <AzCore/std/containers/vector.h>
#include <Azcore/Math/Vector3.h>
#include <AzCore/Math/Vector3.h>
namespace Blast
{