Added SHTextureLibrary stub

This commit is contained in:
Kah Wei 2022-09-20 18:13:13 +08:00
parent c194765889
commit 5f305f9609
2 changed files with 183 additions and 0 deletions

View File

@ -0,0 +1,41 @@
/************************************************************************************//*!
\file SHTextureLibrary.cpp
\author Tng Kah Wei, kahwei.tng, 390009620
\par email: kahwei.tng\@digipen.edu
\date Sep 20, 2022
\brief Contains definitions for all of the functions of the classes that deal
with storage and management of buffers for textures.
Copyright (C) 2022 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent
of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
#include "SHpch.h"
#include "SHTextureLibrary.h"
#include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/Buffers/SHVkBuffer.h"
#include "Graphics/Commands/SHVkCommandBuffer.h"
#include "Graphics/SHVkUtil.h"
namespace SHADE
{
/*-----------------------------------------------------------------------------*/
/* Usage Functions */
/*-----------------------------------------------------------------------------*/
Handle<SHTexture> SHTextureLibrary::Add(uint32_t pixelCount, const SHTexture::PixelChannel* const pixelData)
{
return {};
}
void SHTextureLibrary::Remove(Handle<SHTexture> mesh)
{
}
void SHTextureLibrary::BuildBuffers(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer)
{
}
}

View File

@ -0,0 +1,142 @@
/************************************************************************************//*!
\file SHTextureLibrary.h
\author Tng Kah Wei, kahwei.tng, 390009620
\par email: kahwei.tng\@digipen.edu
\date Sep 20, 2022
\brief Contains definitions for all of the classes that deal with storage and
management of textures.
Copyright (C) 2022 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent
of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
#pragma once
// STL Includes
#include <vector>
// Project Includes
#include "Resource/Handle.h"
#include "Resource/ResourceLibrary.h"
#include "Math/SHMath.h"
namespace SHADE
{
/*---------------------------------------------------------------------------------*/
/* Forward Declarations */
/*---------------------------------------------------------------------------------*/
class SHVkBuffer;
class SHVkLogicalDevice;
class SHVkCommandBuffer;
/*---------------------------------------------------------------------------------*/
/* Type Definitions */
/*---------------------------------------------------------------------------------*/
class SHTexture
{
public:
/*-----------------------------------------------------------------------------*/
/* Type Definitions */
/*-----------------------------------------------------------------------------*/
using PixelChannel = uint8_t;
/*-----------------------------------------------------------------------------*/
/* Data Members */
/*-----------------------------------------------------------------------------*/
};
/***********************************************************************************/
/*!
\brief
Manages storage for all textures in the Graphics System as a single set of
textures.
*/
/***********************************************************************************/
class SHTextureLibrary
{
public:
/*-----------------------------------------------------------------------------*/
/* Usage Functions */
/*-----------------------------------------------------------------------------*/
/*******************************************************************************/
/*!
\brief
Adds a texture to the Texture Library. But this does not mean that the
textures have been added yet. A call to "BuildBuffers()" is required to
transfer all textures into the GPU.
\param pixelCount
Number of pixels in this Mesh.
\param positions
Pointer to the first in a contiguous array of SHMathVec3s that define vertex
positions.
\return
Handle to the created Texture. This is not valid to be used until a call to
BuildBuffers().
*/
/*******************************************************************************/
Handle<SHTexture> Add(uint32_t pixelCount, const SHTexture::PixelChannel* const pixelData);
/*******************************************************************************/
/*!
\brief
Removes a mesh from the Texture Library. But this does not mean that the
textures have been removed yet. A call to "BuildBuffers()" is required to
finalise all changes.
\param mesh
Handle to the mesh to remove.
*/
/*******************************************************************************/
void Remove(Handle<SHTexture> mesh);
/***************************************************************************/
/*!
\brief
Finalises all changes to the Texture Library into the GPU buffers.
\param device
Device used to create and update the buffers.
\param cmdBuffer
Command buffer used to set up transfers of data in the GPU memory. This
call must be preceded by calls to cmdBuffer's BeginRecording() and ended
with EndRecording(). Do recall to also submit the cmdBuffer to a transfer
queue.
*/
/***************************************************************************/
void BuildBuffers(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer);
/*-----------------------------------------------------------------------------*/
/* Getter Functions */
/*-----------------------------------------------------------------------------*/
Handle<SHVkBuffer> GetTextureBuffer() const noexcept { return texStorageBuffer; }
private:
/*-----------------------------------------------------------------------------*/
/* Type Definition */
/*-----------------------------------------------------------------------------*/
struct AddJob
{
uint32_t PixelCount = 0;
const SHTexture::PixelChannel* PixelData = nullptr;
Handle<SHTexture> Handle;
};
/*-----------------------------------------------------------------------------*/
/* Data Members */
/*-----------------------------------------------------------------------------*/
// Manipulation Queues
std::vector<AddJob> addJobs;
std::vector<Handle<SHTexture>> removeJobs;
// Tracking
ResourceLibrary<SHTexture> textures{};
std::vector<Handle<SHTexture>> texOrder;
// CPU Storage
std::vector<SHTexture::PixelChannel> texStorage;
// GPU Storage
Handle<SHVkBuffer> texStorageBuffer{};
// Flags
bool isDirty = true;
};
}