Miscellaneous fixes and PAL changes required for restricted platforms. (#4021)

* Miscellaneous fixes and PAL changes required for restricted platforms.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Rename O3DE::ProjectManager::ProjectUtils::ReplaceFile -> ReplaceProjectFile to prevent conflict with Windows ReplaceFile #define

Signed-off-by: bosnichd <bosnichd@amazon.com>
This commit is contained in:
bosnichd
2021-09-09 12:09:17 -06:00
committed by GitHub
parent d17ac748ac
commit 9976ee2b8e
22 changed files with 172 additions and 143 deletions
@@ -18,6 +18,7 @@
#include <AzCore/std/functional.h>
#include <AzCore/std/parallel/thread.h>
#include <AzCore/std/string/string.h>
#include <AzCore/PlatformIncl.h>
#include <AzFramework/CommandLine/CommandLine.h>
@@ -83,7 +83,7 @@ namespace AzFramework::ProjectManager
return ProjectPathCheckResult::ProjectManagerLaunchFailed;
}
bool LaunchProjectManager(const AZStd::string& commandLineArgs)
bool LaunchProjectManager([[maybe_unused]]const AZStd::string& commandLineArgs)
{
bool launchSuccess = false;
#if (AZ_TRAIT_AZFRAMEWORK_USE_PROJECT_MANAGER)
+3 -2
View File
@@ -6,9 +6,10 @@
*
*/
#include <AzCore/AzCore_Traits_Platform.h>
// Description : Linux/Mac port support for Win32API calls
#if !defined(WIN32)
#if AZ_TRAIT_LEGACY_CRYCOMMON_USE_WINDOWS_STUBS
#include "platform.h" // Note: This should be first to get consistent debugging definitions
@@ -1391,4 +1392,4 @@ __finddata64_t::~__finddata64_t()
}
#endif //defined(APPLE) || defined(LINUX)
#endif // !defined(WIN32)
#endif // AZ_TRAIT_LEGACY_CRYCOMMON_USE_WINDOWS_STUBS
-1
View File
@@ -131,7 +131,6 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
#include "SystemEventDispatcher.h"
#include "HMDBus.h"
#include "zlib.h"
#include "RemoteConsole/RemoteConsole.h"
#include <PNoise3.h>
-4
View File
@@ -273,11 +273,7 @@ static const char* GetLastSystemErrorMessage()
return szBuffer;
}
#else
return 0;
#endif //WIN32
return 0;
}
@@ -441,7 +441,7 @@ namespace O3DE::ProjectManager
return true;
}
bool ReplaceFile(const QString& origFile, const QString& newFile, QWidget* parent, bool interactive)
bool ReplaceProjectFile(const QString& origFile, const QString& newFile, QWidget* parent, bool interactive)
{
QFileInfo original(origFile);
if (original.exists())
@@ -25,7 +25,7 @@ namespace O3DE::ProjectManager
bool DeleteProjectFiles(const QString& path, bool force = false);
bool MoveProject(QString origPath, QString newPath, QWidget* parent, bool skipRegister = false);
bool ReplaceFile(const QString& origFile, const QString& newFile, QWidget* parent = nullptr, bool interactive = true);
bool ReplaceProjectFile(const QString& origFile, const QString& newFile, QWidget* parent = nullptr, bool interactive = true);
bool FindSupportedCompiler(QWidget* parent = nullptr);
AZ::Outcome<void, QString> FindSupportedCompilerForPlatform();
@@ -242,7 +242,7 @@ namespace O3DE::ProjectManager
if (!newProjectSettings.m_newPreviewImagePath.isEmpty())
{
if (!ProjectUtils::ReplaceFile(
if (!ProjectUtils::ReplaceProjectFile(
QDir(newProjectSettings.m_path).filePath(newProjectSettings.m_iconPath), newProjectSettings.m_newPreviewImagePath))
{
QMessageBox::critical(this, tr("File replace failed"), tr("Failed to replace project preview image."));
@@ -202,7 +202,7 @@ namespace O3DE::ProjectManager
TEST_F(ProjectManagerUtilsTests, ReplaceFile_Succeeds)
#endif // !AZ_TRAIT_DISABLE_FAILED_PROJECT_MANAGER_TESTS
{
EXPECT_TRUE(ReplaceFile(m_projectAOrigFilePath, m_projectAReplaceFilePath, nullptr, false));
EXPECT_TRUE(ReplaceProjectFile(m_projectAOrigFilePath, m_projectAReplaceFilePath, nullptr, false));
QFile origFile(m_projectAOrigFilePath);
EXPECT_TRUE(origFile.open(QIODevice::ReadOnly));
@@ -258,6 +258,14 @@ namespace AZ
return RHI::ResultCode::Success;
}
RHI::ResultCode Device::CreateSwapChain(
[[maybe_unused]] const DXGI_SWAP_CHAIN_DESCX& swapChainDesc,
[[maybe_unused]] AZStd::array<RHI::Ptr<ID3D12Resource>, RHI::Limits::Device::FrameCountMax>& outSwapChainResources)
{
AZ_Assert(false, "Wrong Device::CreateSwapChain function called on Windows.");
return RHI::ResultCode::Fail;
}
AZStd::vector<RHI::Format> Device::GetValidSwapChainImageFormats(const RHI::WindowHandle& windowHandle) const
{
AZStd::vector<RHI::Format> formatsList;
@@ -0,0 +1,10 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <RHI/SwapChain_Windows.h>
@@ -5,15 +5,28 @@
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <RHI/SwapChain.h>
#include <RHI/SwapChain_Windows.h>
#include <RHI/Device.h>
#include <RHI/Conversions.h>
#include <RHI/Image.h>
#include <RHI/NsightAftermath.h>
namespace AZ
{
namespace DX12
{
RHI::Ptr<SwapChain> SwapChain::Create()
{
return aznew SwapChain();
}
Device& SwapChain::GetDevice() const
{
return static_cast<Device&>(RHI::SwapChain::GetDevice());
}
RHI::ResultCode SwapChain::InitInternal(RHI::Device& deviceBase, const RHI::SwapChainDescriptor& descriptor, RHI::SwapChainDimensions* nativeDimensions)
{
// Check whether tearing support is available for full screen borderless windowed mode.
@@ -165,6 +178,47 @@ namespace AZ
return GetCurrentImageIndex();
}
RHI::ResultCode SwapChain::InitImageInternal(const InitImageRequest& request)
{
Device& device = GetDevice();
Microsoft::WRL::ComPtr<ID3D12Resource> resource;
DX12::AssertSuccess(m_swapChain->GetBuffer(request.m_imageIndex, IID_GRAPHICS_PPV_ARGS(resource.GetAddressOf())));
D3D12_RESOURCE_ALLOCATION_INFO allocationInfo;
device.GetImageAllocationInfo(request.m_descriptor, allocationInfo);
Name name(AZStd::string::format("SwapChainImage_%d", request.m_imageIndex));
Image& image = static_cast<Image&>(*request.m_image);
image.m_memoryView = MemoryView(resource.Get(), 0, allocationInfo.SizeInBytes, allocationInfo.Alignment, MemoryViewType::Image);
image.SetName(name);
image.GenerateSubresourceLayouts();
// Overwrite m_initialAttachmentState because Swapchain images are created with D3D12_RESOURCE_STATE_COMMON state
image.SetAttachmentState(D3D12_RESOURCE_STATE_COMMON);
RHI::HeapMemoryUsage& memoryUsage = m_memoryUsage.GetHeapMemoryUsage(RHI::HeapMemoryLevel::Device);
memoryUsage.m_reservedInBytes += allocationInfo.SizeInBytes;
memoryUsage.m_residentInBytes += allocationInfo.SizeInBytes;
return RHI::ResultCode::Success;
}
void SwapChain::ShutdownResourceInternal(RHI::Resource& resourceBase)
{
Image& image = static_cast<Image&>(resourceBase);
const size_t sizeInBytes = image.GetMemoryView().GetSize();
RHI::HeapMemoryUsage& memoryUsage = m_memoryUsage.GetHeapMemoryUsage(RHI::HeapMemoryLevel::Device);
memoryUsage.m_reservedInBytes -= sizeInBytes;
memoryUsage.m_residentInBytes -= sizeInBytes;
GetDevice().QueueForRelease(image.m_memoryView);
image.m_memoryView = {};
}
RHI::ResultCode SwapChain::ResizeInternal(const RHI::SwapChainDimensions& dimensions, RHI::SwapChainDimensions* nativeDimensions)
{
GetDevice().WaitForIdle();
@@ -0,0 +1,60 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <Atom/RHI/SwapChain.h>
#include <RHI/DX12.h>
namespace AZ
{
namespace DX12
{
class Device;
class SwapChain
: public RHI::SwapChain
{
public:
AZ_RTTI(SwapChain, "{974AC6A9-5009-47BE-BD7E-61348BF623F0}", RHI::SwapChain);
AZ_CLASS_ALLOCATOR(SwapChain, AZ::SystemAllocator, 0);
static RHI::Ptr<SwapChain> Create();
Device& GetDevice() const;
private:
SwapChain() = default;
friend class SwapChainFactory;
//////////////////////////////////////////////////////////////////////////
// RHI::SwapChain
RHI::ResultCode InitInternal(RHI::Device& deviceBase, const RHI::SwapChainDescriptor& descriptor, RHI::SwapChainDimensions* nativeDimensions) override;
void ShutdownInternal() override;
uint32_t PresentInternal() override;
RHI::ResultCode InitImageInternal(const InitImageRequest& request) override;
void ShutdownResourceInternal(RHI::Resource& resourceBase) override;
RHI::ResultCode ResizeInternal(const RHI::SwapChainDimensions& dimensions, RHI::SwapChainDimensions* nativeDimensions) override;
bool IsExclusiveFullScreenPreferred() const override;
bool GetExclusiveFullScreenState() const override;
bool SetExclusiveFullScreenState(bool fullScreenState) override;
//////////////////////////////////////////////////////////////////////////
void ConfigureDisplayMode(const RHI::SwapChainDimensions& dimensions);
void EnsureColorSpace(const DXGI_COLOR_SPACE_TYPE& colorSpace);
void DisableHdr();
void SetHDRMetaData(float maxOutputNits, float minOutputNits, float maxContentLightLevel, float maxFrameAverageLightLevel);
static const uint32_t InvalidColorSpace = 0xFFFFFFFE;
DXGI_COLOR_SPACE_TYPE m_colorSpace = static_cast<DXGI_COLOR_SPACE_TYPE>(InvalidColorSpace);
RHI::Ptr<IDXGISwapChainX> m_swapChain;
bool m_isInFullScreenExclusiveState = false; //!< Was SetFullscreenState used to enter full screen exclusive state?
bool m_isTearingSupported = false; //!< Is tearing support available for full screen borderless windowed mode?
};
}
}
@@ -22,7 +22,9 @@ set(FILES
RHI/DX12_Windows.cpp
RHI/DX12_Windows.h
RHI/SystemComponent_Windows.cpp
RHI/SwapChain_Platform.h
RHI/SwapChain_Windows.cpp
RHI/SwapChain_Windows.h
RHI/NsightAftermathGpuCrashTracker_Windows.cpp
RHI/NsightAftermathGpuCrashTracker_Windows.h
RHI/NsightAftermath_Windows.cpp
@@ -57,6 +57,10 @@ namespace AZ
const DXGI_SWAP_CHAIN_DESCX& swapChainDesc,
RHI::Ptr<IDXGISwapChainX>& swapChain);
RHI::ResultCode CreateSwapChain(
const DXGI_SWAP_CHAIN_DESCX& swapChainDesc,
AZStd::array<RHI::Ptr<ID3D12Resource>, RHI::Limits::Device::FrameCountMax>& outSwapChainResources);
void GetImageAllocationInfo(
const RHI::ImageDescriptor& descriptor,
D3D12_RESOURCE_ALLOCATION_INFO& info);
@@ -28,11 +28,11 @@ namespace AZ
}
#endif
RHI::ResultCode RayTracingPipelineState::InitInternal(RHI::Device& deviceBase, [[maybe_unused]]const RHI::RayTracingPipelineStateDescriptor* descriptor)
RHI::ResultCode RayTracingPipelineState::InitInternal([[maybe_unused]]RHI::Device& deviceBase, [[maybe_unused]]const RHI::RayTracingPipelineStateDescriptor* descriptor)
{
#ifdef AZ_DX12_DXR_SUPPORT
Device& device = static_cast<Device&>(deviceBase);
#ifdef AZ_DX12_DXR_SUPPORT
size_t dxilLibraryCount = descriptor->GetShaderLibraries().size();
size_t hitGroupCount = descriptor->GetHitGroups().size();
@@ -1,73 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <RHI/SwapChain.h>
#include <RHI/Device.h>
#include <RHI/Conversions.h>
#include <RHI/Image.h>
#include <Atom/RHI/MemoryStatisticsBuilder.h>
#include <Atom/RHI.Reflect/AttachmentEnums.h>
#include <AzCore/std/string/string.h>
#include <AzCore/std/string/conversions.h>
namespace AZ
{
namespace DX12
{
RHI::Ptr<SwapChain> SwapChain::Create()
{
return aznew SwapChain();
}
Device& SwapChain::GetDevice() const
{
return static_cast<Device&>(Base::GetDevice());
}
RHI::ResultCode SwapChain::InitImageInternal(const InitImageRequest& request)
{
Device& device = GetDevice();
Microsoft::WRL::ComPtr<ID3D12Resource> resource;
DX12::AssertSuccess(m_swapChain->GetBuffer(request.m_imageIndex, IID_GRAPHICS_PPV_ARGS(resource.GetAddressOf())));
D3D12_RESOURCE_ALLOCATION_INFO allocationInfo;
device.GetImageAllocationInfo(request.m_descriptor, allocationInfo);
Name name(AZStd::string::format("SwapChainImage_%d", request.m_imageIndex));
Image& image = static_cast<Image&>(*request.m_image);
image.m_memoryView = MemoryView(resource.Get(), 0, allocationInfo.SizeInBytes, allocationInfo.Alignment, MemoryViewType::Image);
image.SetName(name);
image.GenerateSubresourceLayouts();
// Overwrite m_initialAttachmentState because Swapchain images are created with D3D12_RESOURCE_STATE_COMMON state
image.SetAttachmentState(D3D12_RESOURCE_STATE_COMMON);
RHI::HeapMemoryUsage& memoryUsage = m_memoryUsage.GetHeapMemoryUsage(RHI::HeapMemoryLevel::Device);
memoryUsage.m_reservedInBytes += allocationInfo.SizeInBytes;
memoryUsage.m_residentInBytes += allocationInfo.SizeInBytes;
return RHI::ResultCode::Success;
}
void SwapChain::ShutdownResourceInternal(RHI::Resource& resourceBase)
{
Image& image = static_cast<Image&>(resourceBase);
const size_t sizeInBytes = image.GetMemoryView().GetSize();
RHI::HeapMemoryUsage& memoryUsage = m_memoryUsage.GetHeapMemoryUsage(RHI::HeapMemoryLevel::Device);
memoryUsage.m_reservedInBytes -= sizeInBytes;
memoryUsage.m_residentInBytes -= sizeInBytes;
GetDevice().QueueForRelease(image.m_memoryView);
image.m_memoryView = {};
}
}
}
+1 -53
View File
@@ -7,56 +7,4 @@
*/
#pragma once
#include <Atom/RHI/SwapChain.h>
#include <RHI/DX12.h>
namespace AZ
{
namespace DX12
{
class Device;
class Image;
class CommandQueue;
class SwapChain
: public RHI::SwapChain
{
using Base = RHI::SwapChain;
public:
AZ_RTTI(SwapChain, "{974AC6A9-5009-47BE-BD7E-61348BF623F0}", Base);
AZ_CLASS_ALLOCATOR(SwapChain, AZ::SystemAllocator, 0);
static RHI::Ptr<SwapChain> Create();
Device& GetDevice() const;
private:
SwapChain() = default;
//////////////////////////////////////////////////////////////////////////
// RHI::SwapChain
RHI::ResultCode InitInternal(RHI::Device& deviceBase, const RHI::SwapChainDescriptor& descriptor, RHI::SwapChainDimensions* nativeDimensions) override;
void ShutdownInternal() override;
uint32_t PresentInternal() override;
RHI::ResultCode InitImageInternal(const InitImageRequest& request) override;
void ShutdownResourceInternal(RHI::Resource& resourceBase) override;
RHI::ResultCode ResizeInternal(const RHI::SwapChainDimensions& dimensions, RHI::SwapChainDimensions* nativeDimensions) override;
bool IsExclusiveFullScreenPreferred() const override;
bool GetExclusiveFullScreenState() const override;
bool SetExclusiveFullScreenState(bool fullScreenState) override;
//////////////////////////////////////////////////////////////////////////
void ConfigureDisplayMode(const RHI::SwapChainDimensions& dimensions);
void EnsureColorSpace(const DXGI_COLOR_SPACE_TYPE& colorSpace);
void DisableHdr();
void SetHDRMetaData(float maxOutputNits, float minOutputNits, float maxContentLightLevel, float maxFrameAverageLightLevel);
static const uint32_t InvalidColorSpace = 0xFFFFFFFE;
DXGI_COLOR_SPACE_TYPE m_colorSpace = static_cast<DXGI_COLOR_SPACE_TYPE>(InvalidColorSpace);
RHI::Ptr<IDXGISwapChainX> m_swapChain;
bool m_isInFullScreenExclusiveState = false; //!< Was SetFullscreenState used to enter full screen exclusive state?
bool m_isTearingSupported = false; //!< Is tearing support available for full screen borderless windowed mode?
};
}
}
#include <RHI/SwapChain_Platform.h>
@@ -95,7 +95,6 @@ set(FILES
Source/RHI/ShaderResourceGroup.h
Source/RHI/ShaderResourceGroupPool.cpp
Source/RHI/ShaderResourceGroupPool.h
Source/RHI/SwapChain.cpp
Source/RHI/SwapChain.h
Source/RHI/DX12.cpp
Source/RHI/DX12.h
+3
View File
@@ -19,9 +19,12 @@ if(NOT PAL_TRAIT_ATOM_RHI_VULKAN_SUPPORTED)
NAMESPACE Gem
FILES_CMAKE
atom_rhi_vulkan_stub_module.cmake
atom_rhi_vulkan_reflect_common_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Include
Source
${pal_include_dir}
Include/Atom/RHI.Loader/Glad
BUILD_DEPENDENCIES
PRIVATE
@@ -5,6 +5,8 @@
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <Atom/RHI.Reflect/Vulkan/ReflectSystemComponent.h>
#include <AzCore/Module/Module.h>
namespace AZ
@@ -17,7 +19,12 @@ namespace AZ
public:
AZ_RTTI(PlatformModule, "{958CB096-796C-42C7-9B29-17C6FE792C30}", Module);
PlatformModule() = default;
PlatformModule()
{
m_descriptors.insert(m_descriptors.end(), {
ReflectSystemComponent::CreateDescriptor()
});
}
~PlatformModule() override = default;
AZ::ComponentTypeList GetRequiredSystemComponents() const override
@@ -0,0 +1,10 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
set(FILES
)