Merge branch 'SP3-1-Rendering' into SP3-4-editor

This commit is contained in:
Sri Sham Haran 2022-09-09 13:37:10 +08:00
commit b164ecbd16
15 changed files with 90 additions and 30 deletions

View File

@ -59,8 +59,8 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>SBpch.h</PrecompiledHeaderFile>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\Dependencies\spdlog\include;..\SHADE_Engine\src;src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NOMINMAX;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\Dependencies\spdlog\include;$(VULKAN_SDK)\include;..\Dependencies\VMA\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;..\SHADE_Engine\src;src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<MinimalRebuild>false</MinimalRebuild>
@ -79,8 +79,8 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>SBpch.h</PrecompiledHeaderFile>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\Dependencies\spdlog\include;..\SHADE_Engine\src;src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NOMINMAX;_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\Dependencies\spdlog\include;$(VULKAN_SDK)\include;..\Dependencies\VMA\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;..\SHADE_Engine\src;src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>

View File

@ -14,7 +14,8 @@ project "SHADE_Application"
files
{
"%{prj.location}/src/**.h",
"%{prj.location}/src/**.c",
"%{prj.location}/src/**.hpp",
"%{prj.location}/src/**.c",
"%{prj.location}/src/**.cpp",
"%{prj.location}/src/**.glsl",
}
@ -22,6 +23,9 @@ project "SHADE_Application"
includedirs
{
"%{IncludeDir.spdlog}/include",
"%{IncludeDir.VULKAN}/include",
"%{IncludeDir.VMA}/include",
"%{IncludeDir.VULKAN}/Source/SPIRV-Reflect",
"../SHADE_Engine/src",
"src"
}
@ -39,6 +43,11 @@ project "SHADE_Application"
postbuildcommands
{
}
defines
{
"NOMINMAX"
}
warnings 'Extra'

View File

@ -1,5 +1,6 @@
#include "SBpch.h"
#include "SBApplication.h"
#include "Engine/ECS_Base/System/SHSystemManager.h"
#ifdef SHEDITOR
#include "Editor/SHEditor.h"
@ -23,6 +24,11 @@ namespace Sandbox
{
window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
SHADE::SHSystemManager::CreateSystem<SHADE::SHGraphicsSystem>("Graphics System");
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem("Graphics System"));
graphicsSystem->SetWindow(&window);
SHADE::SHSystemManager::Init();
#ifdef SHEDITOR
#else
@ -32,18 +38,24 @@ namespace Sandbox
void SBApplication::Update(void)
{
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem("Graphics System"));
//TODO: Change true to window is open
while (!window.WindowShouldClose())
{
graphicsSystem->BeginRender();
#ifdef SHEDITOR
#else
#endif
}
graphicsSystem->EndRender();
}
}
void SBApplication::Exit(void)
{
SHADE::SHSystemManager::Exit();
#ifdef SHEDITOR
#else
#endif

View File

@ -1,6 +1,7 @@
#ifndef SB_APPLICATION_H
#define SB_APPLICATION_H
#include <Graphics/Windowing/SHWindow.h>
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
//using namespace SHADE;
namespace Sandbox

View File

@ -173,8 +173,11 @@
<ClInclude Include="src\Graphics\Windowing\Surface\SHVkSurface.h" />
<ClInclude Include="src\Meta\SHIsDetected.h" />
<ClInclude Include="src\Resource\Handle.h" />
<ClInclude Include="src\Resource\Handle.hpp" />
<ClInclude Include="src\Resource\ResourceLibrary.h" />
<ClInclude Include="src\Resource\ResourceLibrary.hpp" />
<ClInclude Include="src\Resource\SparseSet.h" />
<ClInclude Include="src\Resource\SparseSet.hpp" />
<ClInclude Include="src\SHpch.h" />
<ClInclude Include="src\Scene\SHScene.h" />
<ClInclude Include="src\Scene\SHSceneManager.h" />

View File

@ -321,12 +321,21 @@
<ClInclude Include="src\Resource\Handle.h">
<Filter>Resource</Filter>
</ClInclude>
<ClInclude Include="src\Resource\Handle.hpp">
<Filter>Resource</Filter>
</ClInclude>
<ClInclude Include="src\Resource\ResourceLibrary.h">
<Filter>Resource</Filter>
</ClInclude>
<ClInclude Include="src\Resource\ResourceLibrary.hpp">
<Filter>Resource</Filter>
</ClInclude>
<ClInclude Include="src\Resource\SparseSet.h">
<Filter>Resource</Filter>
</ClInclude>
<ClInclude Include="src\Resource\SparseSet.hpp">
<Filter>Resource</Filter>
</ClInclude>
<ClInclude Include="src\SHpch.h" />
<ClInclude Include="src\Scene\SHScene.h">
<Filter>Scene</Filter>

View File

@ -12,10 +12,10 @@ project "SHADE_Engine"
files
{
"%{prj.location}/src/**.h",
"%{prj.location}/src/**.hpp",
"%{prj.location}/src/**.c",
"%{prj.location}/src/**.cpp",
"%{prj.location}/src/**.glsl",
"%{wks.location}/Dependencies/stb_image/**.cpp"
"%{prj.location}/src/**.glsl"
}
includedirs

View File

@ -180,10 +180,10 @@ namespace SHADE
return;
}
SHLOG_ERROR("Successfully queried Physical Devices:");
SHLOG_TRACE("Successfully queried Physical Devices:");
for (auto const& device : physicalDevices)
{
SHLOG_ERROR(std::string_view (std::string("\t-") + GetDeviceTypeName(device.getProperties().deviceType) + device.getProperties().deviceName.operator std::string()));
SHLOG_TRACE(std::string_view (std::string("\t-") + GetDeviceTypeName(device.getProperties().deviceType) + device.getProperties().deviceName.operator std::string()));
}
}
}

View File

@ -25,11 +25,8 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
/* Constructor/Destructors */
/*---------------------------------------------------------------------------------*/
SHGraphicsSystem::SHGraphicsSystem(SHWindow& window)
void SHGraphicsSystem::Init(void)
{
// Save the SHWindow
this->window = &window;
// Set Up Instance
SHVkInstance::Init(true, true, true);
@ -39,10 +36,10 @@ namespace SHADE
device = SHVkInstance::CreateLogicalDevice({ SHQueueParams(SH_Q_FAM::GRAPHICS, SH_QUEUE_SELECT::DEDICATED), SHQueueParams(SH_Q_FAM::TRANSFER, SH_QUEUE_SELECT::DEDICATED) }, physicalDevice);
// Construct surface
surface = device->CreateSurface(window.GetHWND());
surface = device->CreateSurface(window->GetHWND());
// Construct Swapchain
auto windowDims = window.GetWindowSize();
auto windowDims = window->GetWindowSize();
swapchain = device->CreateSwapchain(surface, windowDims.first, windowDims.second, SHSwapchainParams
{
.surfaceImageFormats {vk::Format::eB8G8R8A8Unorm, vk::Format::eR8G8B8A8Unorm, vk::Format::eB8G8R8Unorm, vk::Format::eR8G8B8Unorm},
@ -51,7 +48,7 @@ namespace SHADE
.vsyncOn = false, // TODO: Set to true when shipping game
});
window.RegisterWindowSizeCallback([&]([[maybe_unused]] uint32_t width, [[maybe_unused]] uint32_t height)
window->RegisterWindowSizeCallback([&]([[maybe_unused]] uint32_t width, [[maybe_unused]] uint32_t height)
{
renderContext.SetIsResized(true);
});
@ -127,7 +124,13 @@ namespace SHADE
/* RENDERGRAPH END TESTING */
/*-----------------------------------------------------------------------*/
}
SHGraphicsSystem::~SHGraphicsSystem()
void SHGraphicsSystem::Run(float dt)
{
}
void SHGraphicsSystem::Exit(void)
{
//renderPass.Free();
renderContext.Destroy();
@ -235,4 +238,10 @@ namespace SHADE
void SHGraphicsSystem::RemoveSegment(Handle<SHScreenSegment> segment)
{
}
void SHGraphicsSystem::SetWindow(SHWindow* wind) noexcept
{
window = wind;
}
}

View File

@ -21,6 +21,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Graphics/SHVulkanIncludes.h"
#include "Graphics/MiddleEnd/PerFrame/SHRenderContext.h"
#include "Graphics/RenderGraph/SHRenderGraph.h"
#include "Engine/ECS_Base/System/SHSystem.h"
namespace SHADE
{
@ -61,7 +62,7 @@ namespace SHADE
portions of the screen.
*/
/***********************************************************************************/
class SHGraphicsSystem
class SHGraphicsSystem : public SHSystem
{
public:
/*-----------------------------------------------------------------------------*/
@ -72,8 +73,15 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/
/* Constructor/Destructors */
/*-----------------------------------------------------------------------------*/
SHGraphicsSystem(SHWindow& window);
~SHGraphicsSystem();
SHGraphicsSystem (void) = default;
~SHGraphicsSystem(void) noexcept = default;
/*-----------------------------------------------------------------------------*/
/* SHSystem overrides */
/*-----------------------------------------------------------------------------*/
virtual void Init(void) override;
virtual void Run (float dt) override;
virtual void Exit(void) override;
/*-----------------------------------------------------------------------------*/
/* Lifecycle Functions */
@ -93,6 +101,11 @@ namespace SHADE
Handle<SHScreenSegment> AddSegment(const VkViewport& viewport, Handle<SHVkImage> imageToUse);
void RemoveSegment(Handle<SHScreenSegment> segment);
/*-----------------------------------------------------------------------------*/
/* Setters */
/*-----------------------------------------------------------------------------*/
void SetWindow (SHWindow* wind) noexcept;
/*-----------------------------------------------------------------------------*/
/* Getters (Temporary) */
/*-----------------------------------------------------------------------------*/

View File

@ -19,10 +19,14 @@ namespace SHADE
vkPresentModes = physicalDeviceHdl->GetVkPhysicalDevice().getSurfacePresentModesKHR(surfaceHdl->GetVkSurface());
if (vkSurfaceFormats.size() == 0)
{
SHLOG_ERROR("Failed to get surface formats from the physical device. ");
}
if (vkPresentModes.size() == 0)
{
SHLOG_ERROR("Failed to get present modes from the physical device. ");
}
}
vk::SurfaceFormatKHR SHVkSwapchain::ChooseSwapSurfaceFormat(std::vector<vk::SurfaceFormatKHR> const& surfaceFormats) const noexcept

View File

@ -139,7 +139,7 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/
/* Data Members */
/*-----------------------------------------------------------------------------*/
ResourceLibrary<T>* library;
ResourceLibrary<T>* library = nullptr;
/*-----------------------------------------------------------------------------*/
/* Friend Declarations */

View File

@ -69,7 +69,7 @@ namespace SHADE
/* Helper Functions */
/*-----------------------------------------------------------------------------*/
void assertHandleValid(Handle<T> handle) const;
int getAvailableFreeIndex();
uint32_t getAvailableFreeIndex();
};
/// <summary>

View File

@ -35,13 +35,13 @@ namespace SHADE
}
else
{
handle.id.Data.Version = 0;
versionCounts.insert(handle.id.Data.Index, handle.id.Data.Version);
handle.id.Data.Version = 0U;
versionCounts.insert(static_cast<uint32_t>(handle.id.Data.Index), handle.id.Data.Version);
}
handle.library = this;
// Create the resource
[[maybe_unused]] T& obj = objects.insert(handle.id.Data.Index, std::forward<Args>(args) ...);
[[maybe_unused]] T& obj = objects.insert(static_cast<uint32_t>(handle.id.Data.Index), std::forward<Args>(args) ...);
// Handling SelfHandle assignment
if constexpr (std::is_base_of_v<ISelfHandle<T>, T>)
@ -89,7 +89,7 @@ namespace SHADE
}
template<typename T>
inline int ResourceLibrary<T>::getAvailableFreeIndex()
inline uint32_t ResourceLibrary<T>::getAvailableFreeIndex()
{
// Get from the free list if present
if (!freeList.empty())

View File

@ -56,7 +56,7 @@ namespace SHADE
throw std::invalid_argument("An element at this index does not exist!");
// Swap with the last element
const int BACK_IDX = denseArray.size() - 1;
const auto BACK_IDX = denseArray.size() - 1;
std::swap(denseArray[sparseArray[idx]], denseArray.back());
denseArray.pop_back();
// Update the sparse set by swapping the indices
@ -110,7 +110,7 @@ namespace SHADE
// We need to resize the array
if (idx >= sparseArray.size())
{
const int NEW_SIZE = idx + 1;
const auto NEW_SIZE = idx + 1;
sparseArray.resize(NEW_SIZE, INVALID);
inverseSparseArray.resize(NEW_SIZE, INVALID);
}
@ -123,7 +123,7 @@ namespace SHADE
auto& insertedElem = denseArray.emplace_back(std::forward<Args>(args) ...);
// Update sparse and inverse sparse arrays
const index_type DENSE_IDX = denseArray.size() - 1;
const auto DENSE_IDX = static_cast<index_type>(denseArray.size()) - 1;
sparseArray[idx] = DENSE_IDX;
inverseSparseArray[DENSE_IDX] = idx;