修正没有正常RESIZE的问题

This commit is contained in:
hyzboy 2019-07-17 04:49:16 +08:00
parent ad200efa71
commit 7e3b14ce17
3 changed files with 14 additions and 19 deletions

View File

@ -30,12 +30,6 @@ private:
Window * win =nullptr;
vulkan::Instance * inst =nullptr;
void OnResize(int w,int h)
{
InitCommandBuffer();
Resize(w,h);
}
void OnKeyDown (KeyboardButton kb){key_status[kb]=true;}
void OnKeyUp (KeyboardButton kb){key_status[kb]=false;}
void OnKeyPress (KeyboardButton kb){KeyPress(kb);}
@ -60,7 +54,7 @@ protected:
vulkan::ShaderModuleManage * shader_manage =nullptr;
private:
protected:
uint32_t swap_chain_count=0;
@ -115,7 +109,6 @@ public:
if(!device)
return(false);
sc_render_target=device->GetSwapchainRT();
present_complete_semaphore =device->CreateSem();
render_complete_semaphore =device->CreateSem();
@ -143,11 +136,19 @@ public:
virtual void MouseUp(uint){}
virtual void MouseMove(){}
virtual void MouseWheel(int,int,uint){}
void OnResize(int w,int h)
{
InitCommandBuffer();
Resize(w,h);
}
void InitCommandBuffer()
{
if(cmd_buf)
SAFE_CLEAR_OBJECT_ARRAY(cmd_buf,swap_chain_count);
sc_render_target=device->GetSwapchainRT();
swap_chain_count=sc_render_target->GetImageCount();
{

View File

@ -44,6 +44,7 @@ bool Device::Resize(const VkExtent2D &extent)
SAFE_CLEAR(textureSQ);
SAFE_CLEAR(texture_cmd_buf);
attr->Refresh();
swapchain=CreateSwapchain(attr,extent);
texture_cmd_buf=CreateCommandBuffer(extent,0);

View File

@ -21,19 +21,12 @@ namespace
{
VkExtent2D SwapchainExtentClamp(const VkSurfaceCapabilitiesKHR &surface_caps,const VkExtent2D &acquire_extent)
{
if(surface_caps.currentExtent.width==UINT32_MAX)
{
VkExtent2D swapchain_extent;
VkExtent2D swapchain_extent;
swapchain_extent.width =hgl_clamp(acquire_extent.width, surface_caps.minImageExtent.width, surface_caps.maxImageExtent.width );
swapchain_extent.height =hgl_clamp(acquire_extent.height, surface_caps.minImageExtent.height, surface_caps.maxImageExtent.height );
swapchain_extent.width =hgl_clamp(acquire_extent.width, surface_caps.minImageExtent.width, surface_caps.maxImageExtent.width );
swapchain_extent.height =hgl_clamp(acquire_extent.height, surface_caps.minImageExtent.height, surface_caps.maxImageExtent.height );
return swapchain_extent;
}
else
{
return surface_caps.currentExtent;
}
return swapchain_extent;
}
VkSwapchainKHR CreateSwapChain(const DeviceAttribute *dev_attr,const VkExtent2D &extent)