Fixed bugs in SHMaterial, SHMeshLibrary and removed unused functions in SHTextureLibrary

This commit is contained in:
Kah Wei 2022-10-28 19:02:54 +08:00
parent 199897adb4
commit 541f44c039
5 changed files with 9 additions and 73 deletions

View File

@ -33,7 +33,7 @@ namespace SHADE
}
// Get offset and modify the memory directly
T* dataPtr = propMemory.get() + PROP_INFO->offset;
T* dataPtr = reinterpret_cast<T*>(propMemory.get() + PROP_INFO->offset);
*dataPtr = value;
}
template<typename T>
@ -47,7 +47,7 @@ namespace SHADE
}
// Get offset and return the memory directly
T* dataPtr = propMemory.get() + PROP_INFO->offset;
T* dataPtr = reinterpret_cast<T*>(propMemory.get() + PROP_INFO->offset);
return *dataPtr;
}
template<typename T>

View File

@ -69,7 +69,7 @@ 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)
auto prop = std::find_if(overrideData.begin(), overrideData.end(), [&](const OverrideData& data)
{
return PROP_IDX == data.Index;
});
@ -77,7 +77,7 @@ namespace SHADE
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<T*>(dataStore.get() + prop->StoredDataOffset);
return *dataPtr;
}
template<typename T>

View File

@ -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
{

View File

@ -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;
//
//}
}
}

View File

@ -14,8 +14,6 @@ of DigiPen Institute of Technology is prohibited.
// STL Includes
#include <vector>
// 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<vk::ImageMemoryBarrier>& barriers);
vk::Format ddsLoaderToVkFormat(tinyddsloader::DDSFile::DXGIFormat format, bool isLinear);
};
}