From 541f44c039c4b5234d94ffd3f7d2e213c6566bb2 Mon Sep 17 00:00:00 2001 From: Kah Wei Date: Fri, 28 Oct 2022 19:02:54 +0800 Subject: [PATCH] Fixed bugs in SHMaterial, SHMeshLibrary and removed unused functions in SHTextureLibrary --- .../MiddleEnd/Interface/SHMaterial.hpp | 4 +- .../Interface/SHMaterialInstance.hpp | 10 +-- .../MiddleEnd/Interface/SHMeshLibrary.h | 3 +- .../MiddleEnd/Textures/SHTextureLibrary.cpp | 62 ------------------- .../MiddleEnd/Textures/SHTextureLibrary.h | 3 - 5 files changed, 9 insertions(+), 73 deletions(-) diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMaterial.hpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMaterial.hpp index 49587921..dceee512 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMaterial.hpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMaterial.hpp @@ -33,7 +33,7 @@ namespace SHADE } // Get offset and modify the memory directly - T* dataPtr = propMemory.get() + PROP_INFO->offset; + T* dataPtr = reinterpret_cast(propMemory.get() + PROP_INFO->offset); *dataPtr = value; } template @@ -47,7 +47,7 @@ namespace SHADE } // Get offset and return the memory directly - T* dataPtr = propMemory.get() + PROP_INFO->offset; + T* dataPtr = reinterpret_cast(propMemory.get() + PROP_INFO->offset); return *dataPtr; } template diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMaterialInstance.hpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMaterialInstance.hpp index 4621c273..e70631ea 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMaterialInstance.hpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMaterialInstance.hpp @@ -69,15 +69,15 @@ namespace SHADE // Search Override Data for the property uint32_t PROP_IDX = SHADER_INFO->GetVariableIndex(key); - auto prop = std::find(overrideData.begin(), overrideData.end(), [&](const OverrideData& data) - { - return PROP_IDX == data.Index; - }); + auto prop = std::find_if(overrideData.begin(), overrideData.end(), [&](const OverrideData& data) + { + return PROP_IDX == data.Index; + }); if (prop == overrideData.end()) throw std::invalid_argument("Attempted to get an property that was not set previously!"); // Get offset and return the memory directly - T* dataPtr = dataStore.get() + prop->StoredDataOffset; + T* dataPtr = reinterpret_cast(dataStore.get() + prop->StoredDataOffset); return *dataPtr; } template diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMeshLibrary.h b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMeshLibrary.h index 72ac1878..b0cbdce1 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMeshLibrary.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMeshLibrary.h @@ -17,7 +17,8 @@ of DigiPen Institute of Technology is prohibited. // Project Includes #include "Resource/SHHandle.h" #include "Resource/SHResourceLibrary.h" -#include "Math/SHMath.h" +#include "Math/Vector/SHVec2.h" +#include "Math/Vector/SHVec3.h" namespace SHADE { diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.cpp index 5c315ff6..8719458b 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.cpp @@ -214,66 +214,4 @@ namespace SHADE SHLOG_ERROR("Image layouts are invalid. "); } } - - vk::Format SHTextureLibrary::ddsLoaderToVkFormat(tinyddsloader::DDSFile::DXGIFormat format, bool isLinear) - { - switch (format) - { - case tinyddsloader::DDSFile::DXGIFormat::BC1_UNorm: - return vk::Format::eBc1RgbaUnormBlock; - case tinyddsloader::DDSFile::DXGIFormat::BC1_UNorm_SRGB: - return vk::Format::eBc1RgbaSrgbBlock; - case tinyddsloader::DDSFile::DXGIFormat::BC2_UNorm: - case tinyddsloader::DDSFile::DXGIFormat::BC2_UNorm_SRGB: - return isLinear ? vk::Format::eBc2UnormBlock : vk::Format::eBc2SrgbBlock; - case tinyddsloader::DDSFile::DXGIFormat::BC3_UNorm: - case tinyddsloader::DDSFile::DXGIFormat::BC3_UNorm_SRGB: - return isLinear ? vk::Format::eBc3UnormBlock : vk::Format::eBc3SrgbBlock; - case tinyddsloader::DDSFile::DXGIFormat::BC5_UNorm: - case tinyddsloader::DDSFile::DXGIFormat::BC5_SNorm: - return isLinear ? vk::Format::eBc5UnormBlock : vk::Format::eBc5SnormBlock; - case tinyddsloader::DDSFile::DXGIFormat::R8G8B8A8_UNorm: - case tinyddsloader::DDSFile::DXGIFormat::R8G8B8A8_UNorm_SRGB: - return isLinear ? vk::Format::eR8G8B8A8Unorm : vk::Format::eR8G8B8A8Srgb; - case tinyddsloader::DDSFile::DXGIFormat::R8G8B8A8_SNorm: - return vk::Format::eR8G8B8A8Snorm; - case tinyddsloader::DDSFile::DXGIFormat::B8G8R8A8_UNorm: - case tinyddsloader::DDSFile::DXGIFormat::B8G8R8A8_UNorm_SRGB: - return isLinear ? vk::Format::eB8G8R8A8Unorm : vk::Format::eB8G8R8A8Srgb; - case tinyddsloader::DDSFile::DXGIFormat::B8G8R8X8_UNorm: - case tinyddsloader::DDSFile::DXGIFormat::B8G8R8X8_UNorm_SRGB: - return isLinear ? vk::Format::eB8G8R8A8Unorm : vk::Format::eB8G8R8Srgb; - default: - throw std::runtime_error("Unsupported DDS format."); - } - - //switch (format) - //{ - //case tinyddsloader::DDSFile::DXGIFormat::R8G8B8A8_UNorm: - //case tinyddsloader::DDSFile::DXGIFormat::R8G8B8A8_UNorm_SRGB: - // return (isLinear) ? vk::Format::eR8G8B8A8Unorm : vk::Format::eR8G8B8A8Srgb; - // - - //case tinyddsloader::DDSFile::DXGIFormat::B8G8R8A8_UNorm: - //case tinyddsloader::DDSFile::DXGIFormat::B8G8R8A8_UNorm_SRGB: - // return (isLinear) ? vk::Format::eB8G8R8A8Unorm : vk::Format::eB8G8R8A8Srgb; - // - - //case tinyddsloader::DDSFile::DXGIFormat::BC1_UNorm: - //case tinyddsloader::DDSFile::DXGIFormat::BC1_UNorm_SRGB: - // return (isLinear) ? vk::Format::eBc1RgbaUnormBlock : vk::Format::eBc1RgbaSrgbBlock; - - //case tinyddsloader::DDSFile::DXGIFormat::BC2_UNorm: - //case tinyddsloader::DDSFile::DXGIFormat::BC2_UNorm_SRGB: - // return (isLinear) ? vk::Format::eBc2UnormBlock : vk::Format::eBc2SrgbBlock; - - //case tinyddsloader::DDSFile::DXGIFormat::BC3_UNorm: - //case tinyddsloader::DDSFile::DXGIFormat::BC3_UNorm_SRGB: - // return (isLinear) ? vk::Format::eBc3UnormBlock : vk::Format::eBc3SrgbBlock; - - //case tinyddsloader::DDSFile::DXGIFormat::BC5_UNorm: - // return (isLinear) ? vk::Format::eBc5UnormBlock : vk::Format::eBc5SnormBlock; - // - //} - } } diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.h b/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.h index 935a7a4d..9357b0e0 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.h @@ -14,8 +14,6 @@ of DigiPen Institute of Technology is prohibited. // STL Includes #include -// External Dependencies -#include "tinyddsloader.h" // Project Includes #include "Resource/SHHandle.h" #include "Resource/SHResourceLibrary.h" @@ -169,6 +167,5 @@ namespace SHADE /* Helper Functions */ /*-----------------------------------------------------------------------------*/ void preparePipelineBarriers(vk::ImageLayout oldLayout, vk::ImageLayout newLayout, vk::PipelineStageFlagBits& srcStage, vk::PipelineStageFlagBits& dstStage, std::vector& barriers); - vk::Format ddsLoaderToVkFormat(tinyddsloader::DDSFile::DXGIFormat format, bool isLinear); }; }