Wrote handle resize for mouse picking objects
This commit is contained in:
parent
2830dad8e3
commit
0d02ece4c1
|
@ -559,6 +559,8 @@ namespace SHADE
|
|||
|
||||
worldRenderGraph->HandleResize(windowDims.first, windowDims.second);
|
||||
|
||||
mousePickSystem->HandleResize();
|
||||
|
||||
defaultViewport->SetWidth(static_cast<float>(windowDims.first));
|
||||
defaultViewport->SetHeight(static_cast<float>(windowDims.second));
|
||||
|
||||
|
|
|
@ -9,8 +9,10 @@
|
|||
|
||||
namespace SHADE
|
||||
{
|
||||
void SHMousePickSystem::Init(Handle<SHVkLogicalDevice> logicalDevice, std::span<Handle<SHVkCommandPool>> cmdPools, Handle<SHRenderGraphResource> eidAttachment) noexcept
|
||||
void SHMousePickSystem::Init(Handle<SHVkLogicalDevice> device, std::span<Handle<SHVkCommandPool>> cmdPools, Handle<SHRenderGraphResource> eidAttachment) noexcept
|
||||
{
|
||||
logicalDevice = device;
|
||||
|
||||
pickedEID = 0;
|
||||
|
||||
// Create command buffers
|
||||
|
@ -22,13 +24,7 @@ namespace SHADE
|
|||
// assign the attachment
|
||||
entityIDAttachment = eidAttachment;
|
||||
|
||||
// Create the fence
|
||||
afterCopyFence = logicalDevice->CreateFence();
|
||||
|
||||
uint32_t bufferSize = entityIDAttachment->GetWidth() * eidAttachment->GetHeight() * SHVkUtil::GetBytesPerPixelFromFormat(entityIDAttachment->GetResourceFormat());
|
||||
|
||||
// Create the buffer
|
||||
imageDataDstBuffer = logicalDevice->CreateBuffer(bufferSize, nullptr, bufferSize, vk::BufferUsageFlagBits::eTransferDst, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT);
|
||||
HandleResize();
|
||||
}
|
||||
|
||||
void SHMousePickSystem::Run(Handle<SHVkQueue> queue, uint32_t frameIndex) noexcept
|
||||
|
@ -63,6 +59,23 @@ namespace SHADE
|
|||
}
|
||||
}
|
||||
|
||||
void SHMousePickSystem::HandleResize(void) noexcept
|
||||
{
|
||||
if (afterCopyFence)
|
||||
afterCopyFence.Free();
|
||||
|
||||
if (imageDataDstBuffer)
|
||||
imageDataDstBuffer.Free();
|
||||
|
||||
// Create the fence
|
||||
afterCopyFence = logicalDevice->CreateFence();
|
||||
|
||||
uint32_t bufferSize = entityIDAttachment->GetWidth() * entityIDAttachment->GetHeight() * SHVkUtil::GetBytesPerPixelFromFormat(entityIDAttachment->GetResourceFormat());
|
||||
|
||||
// Create the buffer
|
||||
imageDataDstBuffer = logicalDevice->CreateBuffer(bufferSize, nullptr, bufferSize, vk::BufferUsageFlagBits::eTransferDst, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT);
|
||||
}
|
||||
|
||||
EntityID SHMousePickSystem::GetPickedEntity(void) const noexcept
|
||||
{
|
||||
return pickedEID;
|
||||
|
|
|
@ -17,6 +17,8 @@ namespace SHADE
|
|||
class SHMousePickSystem
|
||||
{
|
||||
private:
|
||||
Handle<SHVkLogicalDevice> logicalDevice;
|
||||
|
||||
//! Handle to the render graph resource that will contain the entity IDs
|
||||
Handle<SHRenderGraphResource> entityIDAttachment;
|
||||
|
||||
|
@ -35,8 +37,9 @@ namespace SHADE
|
|||
/*-----------------------------------------------------------------------*/
|
||||
/* PUBLIC MEMBER FUNCTIONS */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
void Init(Handle<SHVkLogicalDevice> logicalDevice, std::span<Handle<SHVkCommandPool>> cmdPools, Handle<SHRenderGraphResource> eidAttachment) noexcept;
|
||||
void Init(Handle<SHVkLogicalDevice> device, std::span<Handle<SHVkCommandPool>> cmdPools, Handle<SHRenderGraphResource> eidAttachment) noexcept;
|
||||
void Run (Handle<SHVkQueue> queue, uint32_t frameIndex) noexcept;
|
||||
void HandleResize (void) noexcept;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* SETTERS AND GETTERS */
|
||||
|
|
Loading…
Reference in New Issue