Resize half working

This commit is contained in:
Brandon Mak 2022-10-16 19:42:44 +08:00
parent c16bea2d39
commit 95ee4b7b55
4 changed files with 26 additions and 8 deletions

View File

@ -71,7 +71,7 @@ namespace SHADE
if (width == 0 || height == 0)
return;
renderContext.SetIsResized(true);
PrepareResize(resizeWidth, resizeHeight);
});
window->RegisterWindowCloseCallback([&](void)
@ -545,6 +545,14 @@ namespace SHADE
);
}
void SHGraphicsSystem::PrepareResize(uint32_t newWidth, uint32_t newHeight) noexcept
{
resizeWidth = newWidth;
resizeHeight = newHeight;
renderContext.SetIsResized(true);
}
void SHGraphicsSystem::HandleResize(void) noexcept
{
if (window->IsMinimized() || renderContext.GetWindowIsDead())
@ -557,15 +565,15 @@ namespace SHADE
renderContext.HandleResize();
worldRenderGraph->HandleResize(windowDims.first, windowDims.second);
worldRenderGraph->HandleResize(resizeWidth, resizeHeight);
mousePickSystem->HandleResize();
//postOffscreenRender->HandleResize();
postOffscreenRender->HandleResize();
defaultViewport->SetWidth(static_cast<float>(windowDims.first));
defaultViewport->SetHeight(static_cast<float>(windowDims.second));
defaultViewport->SetWidth(static_cast<float>(resizeWidth));
defaultViewport->SetHeight(static_cast<float>(resizeHeight));
worldCamera->SetPerspective(90.0f, static_cast<float>(windowDims.first), static_cast<float>(windowDims.second), 0.0f, 100.0f);
worldCamera->SetPerspective(90.0f, static_cast<float>(resizeWidth), static_cast<float>(resizeHeight), 0.0f, 100.0f);
}
void SHGraphicsSystem::AwaitGraphicsExecution()

View File

@ -252,6 +252,7 @@ namespace SHADE
/***************************************************************************/
void BuildTextures();
void PrepareResize(uint32_t newWidth, uint32_t newHeight) noexcept;
void HandleResize(void) noexcept;
void AwaitGraphicsExecution();
@ -331,5 +332,7 @@ namespace SHADE
Handle<SHMousePickSystem> mousePickSystem;
Handle<SHPostOffscreenRenderSystem> postOffscreenRender;
uint32_t resizeWidth;
uint32_t resizeHeight;
};
}

View File

@ -56,14 +56,19 @@ namespace SHADE
};
// Create descriptor set layout
offscreenRenderDescSetLayout = logicalDevice->CreateDescriptorSetLayout(0, { imageBinding }, true);
offscreenRenderDescSetLayout = logicalDevice->CreateDescriptorSetLayout(0, { imageBinding }, false);
// Create descriptor set
offscreenRenderDescSet = descriptorPool->Allocate({ offscreenRenderDescSetLayout }, { 1 });
HandleResize();
}
void SHPostOffscreenRenderSystem::HandleResize(void) noexcept
{
std::vector combinedImageSampler
{
std::make_tuple(renderGraphResource->GetImageView(), Handle<SHVkSampler>{}, vk::ImageLayout::eShaderReadOnlyOptimal),
std::make_tuple(offscreenRender->GetImageView(), offscreenRenderSampler, vk::ImageLayout::eShaderReadOnlyOptimal),
};
// Register the image view and sampler with the descriptor set. Now whenever rendering to the offscreen image is done, the descriptor set will see the change

View File

@ -24,6 +24,8 @@ namespace SHADE
void Init (Handle<SHVkLogicalDevice> logicalDevice, Handle<SHRenderGraphResource> renderGraphResource, Handle<SHVkDescriptorPool> descriptorPool) noexcept;
//void Run ()
void HandleResize (void) noexcept;
Handle<SHVkDescriptorSetGroup> GetDescriptorSetGroup (void) const noexcept;
};
}