Merge remote-tracking branch 'origin/main' into SP3-16-Math

This commit is contained in:
Diren D Bharwani 2022-10-21 16:29:31 +08:00
commit 82e416fe9e
57 changed files with 107 additions and 107 deletions

View File

@ -13,7 +13,7 @@
#include "ECS_Base/SHECSMacros.h"
#include "ECS_Base/System/SHSystem.h"
#include "ECS_Base/System/SHSystemRoutine.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
#include "EditorWindow/SHEditorWindow.h"
#include "Tools/SHLogger.h"

View File

@ -3,7 +3,7 @@
#include "Graphics/SHVulkanIncludes.h"
#include "vk_mem_alloc.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
namespace SHADE
{

View File

@ -4,7 +4,7 @@
#include "Graphics/SHVulkanIncludes.h"
#include "Graphics/SHVulkanDefines.h"
#include "SHCommandPoolResetMode.h"
#include "Resource/ResourceLibrary.h"
#include "Resource/SHResourceLibrary.h"
#include "Graphics/Pipeline/SHVkPipelineLayout.h"
namespace SHADE
@ -36,7 +36,7 @@ namespace SHADE
class SHVkCommandBuffer
{
friend class SHVkCommandPool;
friend class ResourceLibrary<SHVkCommandBuffer>;
friend class SHResourceLibrary<SHVkCommandBuffer>;
static constexpr uint16_t PUSH_CONSTANT_SIZE = 512;
private:

View File

@ -2,7 +2,7 @@
#include "SHVkCommandPool.h"
#include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/Instance/SHVkInstance.h"
#include "Resource/ResourceLibrary.h"
#include "Resource/SHResourceLibrary.h"
#include "Tools/SHLogger.h"
namespace SHADE

View File

@ -6,7 +6,7 @@
#include "Graphics/Queues/SHVkQueue.h"
#include "SHCommandPoolResetMode.h"
#include "SHVkCommandBuffer.h"
#include "Resource/ResourceLibrary.h"
#include "Resource/SHResourceLibrary.h"
namespace SHADE
{

View File

@ -2,7 +2,7 @@
// Project Includes
#include "Graphics/SHVulkanIncludes.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
namespace SHADE
{

View File

@ -4,7 +4,7 @@
// Project Includes
#include "Graphics/SHVulkanIncludes.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
#include "Graphics/Shaders/SHShaderReflected.h"
#include "SHDescriptorSetUpdater.h"

View File

@ -2,7 +2,7 @@
// Project Includes
#include "Graphics/SHVulkanIncludes.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
namespace SHADE
{

View File

@ -8,8 +8,8 @@
#include "Graphics/SHVulkanIncludes.h"
#include "Graphics/Devices/SHVkPhysicalDevice.h"
#include "Graphics/Queues/SHVkQueue.h"
#include "Resource/Handle.h"
#include "Resource/ResourceLibrary.h"
#include "Resource/SHHandle.h"
#include "Resource/SHResourceLibrary.h"
#include "Graphics/Swapchain/SHSwapchainParams.h"
#include "Graphics/Commands/SHCommandPoolResetMode.h"
#include "Graphics/Commands/SHVkCommandPool.h"

View File

@ -2,7 +2,7 @@
#define SH_VK_FRAMEBUFFER_H
#include "Graphics/SHVulkanIncludes.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
#include <span>
namespace SHADE

View File

@ -3,7 +3,7 @@
#include "SHImageViewDetails.h"
#include "Graphics/SHVulkanDefines.h"
#include "Resource/ResourceLibrary.h"
#include "Resource/SHResourceLibrary.h"
#include "vk_mem_alloc.h"
namespace SHADE

View File

@ -2,7 +2,7 @@
#define SH_VK_IMAGE_VIEW_H
#include "Graphics/SHVulkanIncludes.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
#include "SHImageViewDetails.h"
namespace SHADE

View File

@ -15,7 +15,7 @@ of DigiPen Institute of Technology is prohibited.
#include <vector>
// Project Includes
#include "Graphics/SHVulkanIncludes.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
namespace SHADE
{

View File

@ -15,7 +15,7 @@ namespace SHADE
bool SHVkInstance::validationLayersOn;
vk::Instance SHVkInstance::vkInstance;
SHVkDebugMessenger SHVkInstance::debugMessenger;
ResourceManager SHVkInstance::resourceManager;
SHResourceHub SHVkInstance::resourceManager;
/***************************************************************************/
/*!
@ -258,7 +258,7 @@ namespace SHADE
return vkInstance;
}
ResourceManager& SHVkInstance::GetResourceManager(void) noexcept
SHResourceHub& SHVkInstance::GetResourceManager(void) noexcept
{
return resourceManager;
}

View File

@ -18,7 +18,7 @@ written consent of DigiPen Institute of Technology is prohibited.
#include "Graphics/Debugging/SHVkDebugMessenger.h"
#include "Graphics/Devices/SHVkPhysicalDevice.h"
#include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Resource/ResourceLibrary.h"
#include "Resource/SHResourceLibrary.h"
namespace SHADE
@ -61,7 +61,7 @@ namespace SHADE
static SHVkDebugMessenger debugMessenger;
//! Resource management for vulkan project
static ResourceManager resourceManager;
static SHResourceHub resourceManager;
/*-----------------------------------------------------------------------*/
/* PRIVATE MEMBER FUNCTIONS */
@ -85,7 +85,7 @@ namespace SHADE
/* Getters and Setters */
/*-----------------------------------------------------------------------*/
static vk::Instance const& GetVkInstance (void) noexcept;
static ResourceManager& GetResourceManager(void) noexcept;
static SHResourceHub& GetResourceManager(void) noexcept;
};
}

View File

@ -18,7 +18,7 @@ of DigiPen Institute of Technology is prohibited.
// External Dependencies
#include "Graphics/SHVulkanIncludes.h"
// Project Includes
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
#include "Graphics/MiddleEnd/Interface/SHMaterial.h"
#include "Math/SHMatrix.h"
#include "Graphics/MiddleEnd/Interface/SHGraphicsConstants.h"

View File

@ -15,7 +15,7 @@ of DigiPen Institute of Technology is prohibited.
// STL Includes
#include <vector>
// Project Includes
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
namespace SHADE
{

View File

@ -15,7 +15,7 @@ of DigiPen Institute of Technology is prohibited.
// External Dependencies
#include "Graphics/SHVulkanIncludes.h"
// Project Includes
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
#include "SHBatch.h"
#include "Graphics/Pipeline/SHVkPipeline.h"

View File

@ -17,7 +17,7 @@ of DigiPen Institute of Technology is prohibited.
#include <array>
// Project Includes
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
#include "Graphics/SHVulkanIncludes.h"
#include "Graphics/MiddleEnd/PerFrame/SHRenderContext.h"
#include "Graphics/RenderGraph/SHRenderGraph.h"
@ -313,7 +313,7 @@ namespace SHADE
SHWindow* window = nullptr;
// Middle End Resources
ResourceManager resourceManager;
SHResourceHub resourceManager;
SHMeshLibrary meshLibrary;
SHTextureLibrary texLibrary;
SHSamplerCache samplerCache;

View File

@ -15,7 +15,7 @@ of DigiPen Institute of Technology is prohibited.
// STL Includes
#include <unordered_map>
// Project Includes
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
#include "SHCommonTypes.h"
namespace SHADE

View File

@ -13,7 +13,7 @@ of DigiPen Institute of Technology is prohibited.
// STL Includes
#include <memory>
// Project Includes
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
#include "Graphics/Shaders/BlockInterface/SHShaderBlockInterface.h"
#include "SH_API.h"

View File

@ -15,8 +15,8 @@ of DigiPen Institute of Technology is prohibited.
// STL Includes
#include <vector>
// Project Includes
#include "Resource/Handle.h"
#include "Resource/ResourceLibrary.h"
#include "Resource/SHHandle.h"
#include "Resource/SHResourceLibrary.h"
#include "Math/SHMath.h"
namespace SHADE
@ -167,7 +167,7 @@ namespace SHADE
std::vector<MeshAddJob> meshAddJobs;
std::vector<Handle<SHMesh>> meshRemoveJobs;
// Tracking
ResourceLibrary<SHMesh> meshes{};
SHResourceLibrary<SHMesh> meshes{};
std::vector<Handle<SHMesh>> meshOrder;
// CPU Storage
std::vector<SHMesh::VertexPosition> vertPosStorage;

View File

@ -1,6 +1,6 @@
#pragma once
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
namespace SHADE
{

View File

@ -12,7 +12,7 @@ of DigiPen Institute of Technology is prohibited.
#pragma once
// Project Includes
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
//#include "SHTransform.h"
#include "ECS_Base/Components/SHComponent.h"
#include "Math/SHMatrix.h"

View File

@ -17,7 +17,7 @@ of DigiPen Institute of Technology is prohibited.
// Project Includes
#include "SHCamera.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
#include "Graphics/RenderGraph/SHRenderGraph.h"
#include "Math/SHMath.h"
#include <vector>

View File

@ -17,7 +17,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Graphics/Instance/SHVkInstance.h"
#include "Tools/SHLogger.h"
#include "SHRenderer.h"
#include "Resource/ResourceLibrary.h"
#include "Resource/SHResourceLibrary.h"
#include "Graphics/RenderGraph/SHRenderGraph.h"
namespace SHADE
@ -49,7 +49,7 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
/* Renderer Registration Functions */
/*---------------------------------------------------------------------------------*/
Handle<SHRenderer> SHViewport::AddRenderer(ResourceManager& resourceManager, uint32_t numFrames, std::vector<Handle<SHVkCommandPool>>& cmdPools, Handle<SHVkDescriptorPool> descriptorPool, Handle<SHVkDescriptorSetLayout> cameraDescLayout, Handle<SHRenderGraph> renderGraph)
Handle<SHRenderer> SHViewport::AddRenderer(SHResourceHub& resourceManager, uint32_t numFrames, std::vector<Handle<SHVkCommandPool>>& cmdPools, Handle<SHVkDescriptorPool> descriptorPool, Handle<SHVkDescriptorSetLayout> cameraDescLayout, Handle<SHRenderGraph> renderGraph)
{
// Create the renderer
auto renderer = resourceManager.Create<SHRenderer>(device, numFrames, cmdPools, descriptorPool, cameraDescLayout, GetHandle(), renderGraph);

View File

@ -17,7 +17,7 @@ of DigiPen Institute of Technology is prohibited.
// External Dependencies
#include "Graphics/SHVulkanIncludes.h"
// Project Includes
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
namespace SHADE
{
@ -28,7 +28,7 @@ namespace SHADE
class SHVkCommandBuffer;
class SHVkLogicalDevice;
class SHVkImageView;
class ResourceManager;
class SHResourceHub;
class SHRenderGraph;
class SHVkDescriptorPool;
class SHVkDescriptorSetLayout;
@ -59,7 +59,7 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/
/* Renderers Registration Functions */
/*-----------------------------------------------------------------------------*/
Handle<SHRenderer> AddRenderer(ResourceManager& resourceManager, uint32_t numFrames, std::vector<Handle<SHVkCommandPool>>& cmdPools, Handle<SHVkDescriptorPool> descriptorPool, Handle<SHVkDescriptorSetLayout> cameraDescLayout, Handle<SHRenderGraph> renderGraph);
Handle<SHRenderer> AddRenderer(SHResourceHub& resourceManager, uint32_t numFrames, std::vector<Handle<SHVkCommandPool>>& cmdPools, Handle<SHVkDescriptorPool> descriptorPool, Handle<SHVkDescriptorSetLayout> cameraDescLayout, Handle<SHRenderGraph> renderGraph);
void RemoveRenderer(Handle<SHRenderer> renderer);
/*-----------------------------------------------------------------------------*/

View File

@ -14,7 +14,7 @@ of DigiPen Institute of Technology is prohibited.
#include "SHMaterialInstanceCache.h"
#include "Graphics/MiddleEnd/Interface/SHMaterialInstance.h"
#include "Resource/ResourceLibrary.h"
#include "Resource/SHResourceLibrary.h"
namespace SHADE
@ -22,7 +22,7 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
/* Usage Functions */
/*---------------------------------------------------------------------------------*/
SHADE::Handle<SHADE::SHMaterialInstance> SHMaterialInstanceCache::CreateOrGet(ResourceManager& manager, Handle<SHMaterial> material)
SHADE::Handle<SHADE::SHMaterialInstance> SHMaterialInstanceCache::CreateOrGet(SHResourceHub& manager, Handle<SHMaterial> material)
{
// Check if there is already an existing instance
auto matInst = cache.find(material);

View File

@ -15,7 +15,7 @@ of DigiPen Institute of Technology is prohibited.
// STL Includes
#include <unordered_map>
// Project Includes
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
namespace SHADE
{
@ -24,7 +24,7 @@ namespace SHADE
/*-----------------------------------------------------------------------------------*/
class SHMaterial;
class SHMaterialInstance;
class ResourceManager;
class SHResourceHub;
/*-----------------------------------------------------------------------------------*/
/* Type Definitions */
@ -56,7 +56,7 @@ namespace SHADE
*/
/***********************************************************************************/
Handle<SHMaterialInstance> CreateOrGet(ResourceManager& manager, Handle<SHMaterial> material);
Handle<SHMaterialInstance> CreateOrGet(SHResourceHub& manager, Handle<SHMaterial> material);
/***********************************************************************************/
/*!

View File

@ -17,8 +17,8 @@ of DigiPen Institute of Technology is prohibited.
// External Dependencies
#include "tinyddsloader.h"
// Project Includes
#include "Resource/Handle.h"
#include "Resource/ResourceLibrary.h"
#include "Resource/SHHandle.h"
#include "Resource/SHResourceLibrary.h"
#include "Math/SHMath.h"
#include "Graphics/SHVulkanIncludes.h"
@ -156,7 +156,7 @@ namespace SHADE
std::vector<AddJob> addJobs;
std::vector<Handle<SHTexture>> removeJobs;
// Tracking
ResourceManager resourceManager;
SHResourceHub resourceManager;
std::vector<Handle<SHTexture>> texOrder;
// CPU Storage
std::vector<std::tuple<Handle<SHVkImageView>, Handle<SHVkSampler>, vk::ImageLayout>> combinedImageSamplers;

View File

@ -16,7 +16,7 @@ of DigiPen Institute of Technology is prohibited.
// External Dependencies
#include "Graphics/SHVulkanIncludes.h"
// Project Includes
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
namespace SHADE
{

View File

@ -2,7 +2,7 @@
#define SH_PIPELINE_LAYOUT_PARAMS_H
#include "Graphics/SHVulkanIncludes.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
#include "Graphics/Descriptors/SHVkDescriptorSetLayout.h"
namespace SHADE

View File

@ -3,7 +3,7 @@
#include "SHPipelineState.h"
#include "SHPipelineType.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
#include "Graphics/Pipeline/SHVkPipelineLayout.h"
namespace SHADE

View File

@ -3,7 +3,7 @@
#include "Graphics/SHVulkanIncludes.h"
#include "Graphics/SHVulkanDefines.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
namespace SHADE
{

View File

@ -1,6 +1,6 @@
#pragma once
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
namespace SHADE
{

View File

@ -367,7 +367,7 @@ namespace SHADE
, graphResources{}
, resourceManager{nullptr}
{
resourceManager = std::make_shared<ResourceManager>();
resourceManager = std::make_shared<SHResourceHub>();
}
SHRenderGraph::SHRenderGraph(SHRenderGraph&& rhs) noexcept

View File

@ -2,7 +2,7 @@
#define SH_RENDER_GRAPH_H
#include "Graphics/Renderpass/SHVkRenderpass.h"
#include "Resource/ResourceLibrary.h"
#include "Resource/SHResourceLibrary.h"
#include "SH_API.h"
#include "Graphics/MiddleEnd/Pipeline/SHPipelineLibrary.h"
#include "Graphics/MiddleEnd/Batching/SHSuperBatch.h"
@ -71,7 +71,7 @@ namespace SHADE
std::unordered_map<std::string, Handle<SHRenderGraphResource>> graphResources;
//! Resource library for graph handles
std::shared_ptr<ResourceManager> resourceManager;
std::shared_ptr<SHResourceHub> resourceManager;
public:
/*-----------------------------------------------------------------------*/

View File

@ -104,7 +104,7 @@ namespace SHADE
*/
/***************************************************************************/
SHRenderGraphNode::SHRenderGraphNode(std::shared_ptr<ResourceManager> rm, Handle<SHVkLogicalDevice> const& logicalDevice, Handle<SHVkSwapchain> const& swapchain, std::vector<SHAttachmentDescInitParams> attDescInitParams, std::vector<Handle<SHRenderGraphNode>> predecessors, std::unordered_map<std::string, Handle<SHRenderGraphResource>> const* resources) noexcept
SHRenderGraphNode::SHRenderGraphNode(std::shared_ptr<SHResourceHub> rm, Handle<SHVkLogicalDevice> const& logicalDevice, Handle<SHVkSwapchain> const& swapchain, std::vector<SHAttachmentDescInitParams> attDescInitParams, std::vector<Handle<SHRenderGraphNode>> predecessors, std::unordered_map<std::string, Handle<SHRenderGraphResource>> const* resources) noexcept
: logicalDeviceHdl{ logicalDevice }
, renderpass{}
, framebuffers{}

View File

@ -13,7 +13,7 @@
namespace SHADE
{
class ResourceManager;
class SHResourceHub;
class SHVkFramebuffer;
class SHRenderGraphResource;
class SHVkLogicalDevice;
@ -26,7 +26,7 @@ namespace SHADE
/*-----------------------------------------------------------------------*/
/* PRIVATE MEMBER VARIABLES */
/*-----------------------------------------------------------------------*/
std::shared_ptr<ResourceManager> resourceManager;
std::shared_ptr<SHResourceHub> resourceManager;
//! For Vulkan object creation
Handle<SHVkLogicalDevice> logicalDeviceHdl;
@ -88,7 +88,7 @@ namespace SHADE
/*-----------------------------------------------------------------------*/
/* CTORS AND DTORS */
/*-----------------------------------------------------------------------*/
SHRenderGraphNode(std::shared_ptr<ResourceManager> rm, Handle<SHVkLogicalDevice> const& logicalDevice, Handle<SHVkSwapchain> const& swapchain, std::vector<SHAttachmentDescInitParams> attDescInitParams, std::vector<Handle<SHRenderGraphNode>> predecessors, std::unordered_map<std::string, Handle<SHRenderGraphResource>> const* resources) noexcept;
SHRenderGraphNode(std::shared_ptr<SHResourceHub> rm, Handle<SHVkLogicalDevice> const& logicalDevice, Handle<SHVkSwapchain> const& swapchain, std::vector<SHAttachmentDescInitParams> attDescInitParams, std::vector<Handle<SHRenderGraphNode>> predecessors, std::unordered_map<std::string, Handle<SHRenderGraphResource>> const* resources) noexcept;
SHRenderGraphNode(SHRenderGraphNode&& rhs) noexcept;
SHRenderGraphNode& operator= (SHRenderGraphNode&& rhs) noexcept;

View File

@ -3,7 +3,7 @@
#include <string>
#include "SHAttachmentDescriptionType.h"
#include <vector>
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
#include "Graphics/SHVulkanIncludes.h"
#include "SH_API.h"

View File

@ -182,7 +182,7 @@ namespace SHADE
exteriorDrawCalls.push_back(newDrawCall);
}
void SHSubpass::Init(ResourceManager& resourceManager) noexcept
void SHSubpass::Init(SHResourceHub& resourceManager) noexcept
{
superBatch = resourceManager.Create<SHSuperBatch>(GetHandle());

View File

@ -3,7 +3,7 @@
#include "SHAttachmentDescriptionType.h"
#include <string>
#include "SH_API.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
#include "Graphics/SHVulkanIncludes.h"
@ -78,7 +78,7 @@ namespace SHADE
void Execute(Handle<SHVkCommandBuffer>& commandBuffer, Handle<SHVkDescriptorPool> descPool, uint32_t frameIndex) noexcept;
void AddExteriorDrawCalls(std::function<void(Handle<SHVkCommandBuffer>&)> const& newDrawCall) noexcept;
void Init(ResourceManager& resourceManager) noexcept;
void Init(SHResourceHub& resourceManager) noexcept;
/*-----------------------------------------------------------------------*/
/* GETTERS AND SETTERS */

View File

@ -1,6 +1,6 @@
#pragma once
#include <Resource/Handle.h>
#include <Resource/SHHandle.h>
namespace SHADE
{

View File

@ -2,7 +2,7 @@
#define SH_VK_ATTACHMENT_DESC_GEN_H
#include "Graphics/SHVulkanIncludes.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
namespace SHADE
{

View File

@ -3,7 +3,7 @@
#include "SHVkAttachDescGen.h"
#include "SHVkSubpassParams.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
#include <span>
namespace SHADE

View File

@ -2,7 +2,7 @@
#define SH_VK_SUBPASS_PARAMS_H
#include "Graphics/SHVulkanIncludes.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
#include <span>
namespace SHADE

View File

@ -3,7 +3,7 @@
#include "SHVulkanIncludes.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
namespace SHADE
{

View File

@ -2,7 +2,7 @@
#define SH_VK_SHADER_MODULE_H
#include "Graphics/SHVulkanIncludes.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
#include "SHShaderReflected.h"
#include <vector>

View File

@ -4,7 +4,7 @@
#include <cstdint>
#include <vector>
#include "Graphics/SHVulkanIncludes.h"
#include "Resource/ResourceLibrary.h"
#include "Resource/SHResourceLibrary.h"
#include "Graphics/Swapchain/SHSwapchainParams.h"
namespace SHADE

View File

@ -2,7 +2,7 @@
#define SH_VK_FENCE_H
#include "Graphics/SHVulkanIncludes.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
namespace SHADE
{

View File

@ -2,7 +2,7 @@
#define SH_VK_SEMAPHORE_H
#include "Graphics/SHVulkanIncludes.h"
#include "Resource/Handle.h"
#include "Resource/SHHandle.h"
namespace SHADE
{

View File

@ -3,7 +3,7 @@
#include <windows.h>
#include "Graphics/SHVulkanIncludes.h"
#include "Resource/ResourceLibrary.h"
#include "Resource/SHResourceLibrary.h"
namespace SHADE
{

View File

@ -9,7 +9,7 @@ namespace SHADE
/* Forward Declarations */
/*---------------------------------------------------------------------------------*/
template<typename T>
class ResourceLibrary;
class SHResourceLibrary;
/*---------------------------------------------------------------------------------*/
/* Type Definitions */
@ -140,12 +140,12 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/
/* Data Members */
/*-----------------------------------------------------------------------------*/
ResourceLibrary<T>* library = nullptr;
SHResourceLibrary<T>* library = nullptr;
/*-----------------------------------------------------------------------------*/
/* Friend Declarations */
/*-----------------------------------------------------------------------------*/
friend class ResourceLibrary<T>;
friend class SHResourceLibrary<T>;
};
/// <summary>
@ -183,7 +183,7 @@ namespace SHADE
/// </summary>
/// <param name="rscLib">Required to lock usage to ResourceLibrary only.</param>
/// <param name="hdl">Handle to set.</param>
void SetHandle(const ResourceLibrary<T>& rscLib, Handle<T> hdl);
void SetHandle(const SHResourceLibrary<T>& rscLib, Handle<T> hdl);
private:
/*-----------------------------------------------------------------------------*/
@ -220,4 +220,4 @@ namespace std
};
}
#include "Handle.hpp"
#include "SHHandle.hpp"

View File

@ -1,7 +1,7 @@
#pragma once
// Primary Header
#include "Handle.h"
#include "ResourceLibrary.h"
#include "SHHandle.h"
#include "SHResourceLibrary.h"
namespace SHADE
{
@ -96,7 +96,7 @@ namespace SHADE
return handle;
}
template<typename T>
inline void ISelfHandle<T>::SetHandle(const ResourceLibrary<T>&, Handle<T> hdl)
inline void ISelfHandle<T>::SetHandle(const SHResourceLibrary<T>&, Handle<T> hdl)
{
handle = hdl;
}

View File

@ -1,11 +1,11 @@
#include "SHPch.h"
#include "ResourceLibrary.h"
#include "SHResourceLibrary.h"
namespace SHADE
{
/*-----------------------------------------------------------------------------*/
/* Constructors/Destructors */
/*-----------------------------------------------------------------------------*/
ResourceManager::~ResourceManager()
SHResourceHub::~SHResourceHub()
{
// Delete all resources libraries
for (auto iter = deleters.rbegin(); iter != deleters.rend(); ++iter)

View File

@ -6,7 +6,7 @@
#include <queue>
// Project Headers
#include "Handle.h"
#include "SHHandle.h"
#include "Resource/SparseSet.h"
namespace SHADE
@ -17,13 +17,13 @@ namespace SHADE
/// </summary>
/// <typeparam name="T">Type of resources that this library stores.</typeparam>
template<typename T>
class ResourceLibrary
class SHResourceLibrary
{
public:
/*-----------------------------------------------------------------------------*/
/* Constructor */
/*-----------------------------------------------------------------------------*/
ResourceLibrary();
SHResourceLibrary();
/*-----------------------------------------------------------------------------*/
/* Usage Functions */
@ -75,13 +75,13 @@ namespace SHADE
/// <summary>
/// Manages all resources in multiple ResourceLibraries.
/// </summary>
class ResourceManager final
class SHResourceHub final
{
public:
/*-----------------------------------------------------------------------------*/
/* Constructors/Destructors */
/*-----------------------------------------------------------------------------*/
~ResourceManager();
~SHResourceHub();
/*-----------------------------------------------------------------------------*/
/* Usage Functions */
@ -136,10 +136,10 @@ namespace SHADE
/* Helper Functions */
/*-----------------------------------------------------------------------------*/
template<typename T>
ResourceLibrary<T>& getLibrary();
SHResourceLibrary<T>& getLibrary();
template<typename T>
const ResourceLibrary<T>& getLibrary() const;
const SHResourceLibrary<T>& getLibrary() const;
};
}
#include "ResourceLibrary.hpp"
#include "SHResourceLibrary.hpp"

View File

@ -1,6 +1,6 @@
#pragma once
// Primary Header
#include "ResourceLibrary.h"
#include "SHResourceLibrary.h"
// Standard Library
#include <utility>
@ -10,7 +10,7 @@ namespace SHADE
/* ResourceLibrary - Constructor */
/*---------------------------------------------------------------------------------*/
template <typename T>
ResourceLibrary<T>::ResourceLibrary()
SHResourceLibrary<T>::SHResourceLibrary()
{
// Type Checking
//static_assert(std::is_copy_assignable_v<T>, "Resource Library's resources must be copy assignable.");
@ -24,7 +24,7 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
template <typename T>
template <typename ... Args>
Handle<T> ResourceLibrary<T>::Create(Args&&... args)
Handle<T> SHResourceLibrary<T>::Create(Args&&... args)
{
// Create the handle
Handle<T> handle;
@ -55,7 +55,7 @@ namespace SHADE
}
template <typename T>
void ResourceLibrary<T>::Free(Handle<T> handle)
void SHResourceLibrary<T>::Free(Handle<T> handle)
{
assertHandleValid(handle);
@ -63,7 +63,7 @@ namespace SHADE
}
template <typename T>
T& ResourceLibrary<T>::Get(Handle<T> handle)
T& SHResourceLibrary<T>::Get(Handle<T> handle)
{
assertHandleValid(handle);
@ -71,7 +71,7 @@ namespace SHADE
}
template <typename T>
const T& ResourceLibrary<T>::Get(Handle<T> handle) const
const T& SHResourceLibrary<T>::Get(Handle<T> handle) const
{
assertHandleValid(handle);
@ -82,14 +82,14 @@ namespace SHADE
/* ResourceLibrary - Helper Functions */
/*---------------------------------------------------------------------------------*/
template <typename T>
void ResourceLibrary<T>::assertHandleValid(Handle<T> handle) const
void SHResourceLibrary<T>::assertHandleValid(Handle<T> handle) const
{
if (!handle || handle.id.Data.Version != versionCounts[handle.id.Data.Index])
throw std::invalid_argument("Invalid handle provided!");
}
template<typename T>
inline uint32_t ResourceLibrary<T>::getAvailableFreeIndex()
inline uint32_t SHResourceLibrary<T>::getAvailableFreeIndex()
{
// Get from the free list if present
if (!freeList.empty())
@ -107,25 +107,25 @@ namespace SHADE
/* ResourceManager - Usage Functions */
/*---------------------------------------------------------------------------------*/
template <typename T, typename ... Args>
Handle<T> ResourceManager::Create(Args&&... args)
Handle<T> SHResourceHub::Create(Args&&... args)
{
return getLibrary<T>().Create(std::forward<Args>(args) ...);
}
template <typename T>
void ResourceManager::Free(Handle<T> handle)
void SHResourceHub::Free(Handle<T> handle)
{
getLibrary<T>().Free(handle);
}
template <typename T>
T& ResourceManager::Get(Handle<T> handle)
T& SHResourceHub::Get(Handle<T> handle)
{
return getLibrary<T>().Get(handle);
}
template <typename T>
const T& ResourceManager::Get(Handle<T> handle) const
const T& SHResourceHub::Get(Handle<T> handle) const
{
return getLibrary<T>().Get(handle);
}
@ -134,18 +134,18 @@ namespace SHADE
/* ResourceManager - Helper Functions */
/*-----------------------------------------------------------------------------*/
template <typename T>
ResourceLibrary<T>& ResourceManager::getLibrary()
SHResourceLibrary<T>& SHResourceHub::getLibrary()
{
// Attempt to retrieve the library
const std::type_index RSC_TYPE = typeid(T);
if (resourceLibs.contains(RSC_TYPE))
{
return *static_cast<ResourceLibrary<T>*>(resourceLibs.at(RSC_TYPE));
return *static_cast<SHResourceLibrary<T>*>(resourceLibs.at(RSC_TYPE));
}
else
{
// Construct library if doesn't exist
ResourceLibrary<T>* lib = new ResourceLibrary<T>();
SHResourceLibrary<T>* lib = new SHResourceLibrary<T>();
resourceLibs.emplace(RSC_TYPE, static_cast<void*>(lib));
// Construct deleter to properly delete objects with void*
@ -156,8 +156,8 @@ namespace SHADE
}
template <typename T>
const ResourceLibrary<T>& ResourceManager::getLibrary() const
const SHResourceLibrary<T>& SHResourceHub::getLibrary() const
{
return const_cast<ResourceManager*>(this).getLibrary<T>();
return const_cast<SHResourceHub*>(this).getLibrary<T>();
}
}