Adding benchmark
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
#include "Window/WindowManager.h"
|
||||
#include "ktx.h"
|
||||
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
#define KTX_ASSERT(x) \
|
||||
@@ -24,35 +23,17 @@ TextureAsset::TextureAsset(std::string_view folderPath, std::string_view name) :
|
||||
TextureAsset::~TextureAsset() {}
|
||||
|
||||
void TextureAsset::save(ArchiveBuffer& buffer) const {
|
||||
// ktxBasisParams basisParams = {
|
||||
// .structSize = sizeof(ktxBasisParams),
|
||||
// .uastc = true,
|
||||
// .threadCount = std::thread::hardware_concurrency(),
|
||||
// .normalMap = normalMap,
|
||||
// .uastcFlags = KTX_PACK_UASTC_LEVEL_VERYSLOW,
|
||||
// .uastcRDO = true,
|
||||
// .uastcRDOQualityScalar = 1,
|
||||
// };
|
||||
// KTX_ASSERT(ktxTexture2_CompressBasisEx(ktxHandle, &basisParams));
|
||||
// KTX_ASSERT(ktxTexture2_DeflateZstd(ktxHandle, 20));
|
||||
// ktx_uint8_t* texData;
|
||||
// ktx_size_t texSize;
|
||||
// KTX_ASSERT(ktxTexture_WriteToMemory(ktxTexture(ktxHandle), &texData, &texSize));
|
||||
//
|
||||
// Array<uint8> rawData(texSize);
|
||||
// std::memcpy(rawData.data(), texData, texSize);
|
||||
// Serialization::save(buffer, rawData);
|
||||
// free(texData);
|
||||
Serialization::save(buffer, ktxData);
|
||||
}
|
||||
|
||||
void TextureAsset::load(ArchiveBuffer& buffer) {
|
||||
std::string ktxPath;
|
||||
Serialization::load(buffer, ktxPath);
|
||||
ktxTexture2* ktxHandle;
|
||||
Serialization::load(buffer, ktxData);
|
||||
KTX_ASSERT(
|
||||
ktxTexture_CreateFromMemory(ktxData.data(), ktxData.size(), KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT, (ktxTexture**)&ktxHandle));
|
||||
|
||||
KTX_ASSERT(ktxTexture_CreateFromNamedFile(ktxPath.c_str(), KTX_TEXTURE_CREATE_NO_FLAGS, (ktxTexture**)&ktxHandle));
|
||||
|
||||
KTX_ASSERT(ktxTexture2_TranscodeBasis(ktxHandle, KTX_TTF_BC7_RGBA, 0));
|
||||
ktxTexture2_TranscodeBasis(ktxHandle, KTX_TTF_RGBA32, 0);
|
||||
//ktxTexture2_DeflateZstd(ktxHandle, 0);
|
||||
|
||||
Gfx::PGraphics graphics = buffer.getGraphics();
|
||||
TextureCreateInfo createInfo = {
|
||||
@@ -60,7 +41,7 @@ void TextureAsset::load(ArchiveBuffer& buffer) {
|
||||
{
|
||||
.size = ktxTexture_GetDataSize(ktxTexture(ktxHandle)),
|
||||
.data = ktxTexture_GetData(ktxTexture(ktxHandle)),
|
||||
.owner = Gfx::QueueType::TRANSFER,
|
||||
.owner = Gfx::QueueType::GRAPHICS,
|
||||
},
|
||||
.format = (Gfx::SeFormat)ktxHandle->vkFormat,
|
||||
.width = ktxHandle->baseWidth,
|
||||
@@ -79,12 +60,9 @@ void TextureAsset::load(ArchiveBuffer& buffer) {
|
||||
texture = graphics->createTexture2D(createInfo);
|
||||
}
|
||||
|
||||
texture->transferOwnership(Gfx::QueueType::GRAPHICS);
|
||||
ktxTexture_Destroy(ktxTexture(ktxHandle));
|
||||
}
|
||||
|
||||
void TextureAsset::setTexture(Gfx::OTexture _texture) { texture = std::move(_texture); }
|
||||
|
||||
uint32 TextureAsset::getWidth() { return texture->getWidth(); }
|
||||
|
||||
uint32 TextureAsset::getHeight() { return texture->getHeight(); }
|
||||
|
||||
@@ -12,14 +12,14 @@ class TextureAsset : public Asset {
|
||||
virtual ~TextureAsset();
|
||||
virtual void save(ArchiveBuffer& buffer) const override;
|
||||
virtual void load(ArchiveBuffer& buffer) override;
|
||||
void setTexture(Gfx::OTexture _texture);
|
||||
Gfx::PTexture getTexture() { return texture; }
|
||||
void setTexture(Array<uint8> data) { ktxData = std::move(data); }
|
||||
uint32 getWidth();
|
||||
uint32 getHeight();
|
||||
|
||||
private:
|
||||
Gfx::OTexture texture;
|
||||
bool normalMap;
|
||||
Array<uint8> ktxData;
|
||||
friend class TextureLoader;
|
||||
};
|
||||
DEFINE_REF(TextureAsset)
|
||||
|
||||
Reference in New Issue
Block a user