修正没有正常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; Window * win =nullptr;
vulkan::Instance * inst =nullptr; vulkan::Instance * inst =nullptr;
void OnResize(int w,int h)
{
InitCommandBuffer();
Resize(w,h);
}
void OnKeyDown (KeyboardButton kb){key_status[kb]=true;} void OnKeyDown (KeyboardButton kb){key_status[kb]=true;}
void OnKeyUp (KeyboardButton kb){key_status[kb]=false;} void OnKeyUp (KeyboardButton kb){key_status[kb]=false;}
void OnKeyPress (KeyboardButton kb){KeyPress(kb);} void OnKeyPress (KeyboardButton kb){KeyPress(kb);}
@ -60,7 +54,7 @@ protected:
vulkan::ShaderModuleManage * shader_manage =nullptr; vulkan::ShaderModuleManage * shader_manage =nullptr;
private: protected:
uint32_t swap_chain_count=0; uint32_t swap_chain_count=0;
@ -115,7 +109,6 @@ public:
if(!device) if(!device)
return(false); return(false);
sc_render_target=device->GetSwapchainRT();
present_complete_semaphore =device->CreateSem(); present_complete_semaphore =device->CreateSem();
render_complete_semaphore =device->CreateSem(); render_complete_semaphore =device->CreateSem();
@ -144,11 +137,19 @@ public:
virtual void MouseMove(){} virtual void MouseMove(){}
virtual void MouseWheel(int,int,uint){} virtual void MouseWheel(int,int,uint){}
void OnResize(int w,int h)
{
InitCommandBuffer();
Resize(w,h);
}
void InitCommandBuffer() void InitCommandBuffer()
{ {
if(cmd_buf) if(cmd_buf)
SAFE_CLEAR_OBJECT_ARRAY(cmd_buf,swap_chain_count); SAFE_CLEAR_OBJECT_ARRAY(cmd_buf,swap_chain_count);
sc_render_target=device->GetSwapchainRT();
swap_chain_count=sc_render_target->GetImageCount(); swap_chain_count=sc_render_target->GetImageCount();
{ {
const VkExtent2D extent=sc_render_target->GetExtent(); const VkExtent2D extent=sc_render_target->GetExtent();

View File

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

View File

@ -20,8 +20,6 @@ Swapchain::~Swapchain()
namespace namespace
{ {
VkExtent2D SwapchainExtentClamp(const VkSurfaceCapabilitiesKHR &surface_caps,const VkExtent2D &acquire_extent) VkExtent2D SwapchainExtentClamp(const VkSurfaceCapabilitiesKHR &surface_caps,const VkExtent2D &acquire_extent)
{
if(surface_caps.currentExtent.width==UINT32_MAX)
{ {
VkExtent2D swapchain_extent; VkExtent2D swapchain_extent;
@ -30,11 +28,6 @@ namespace
return swapchain_extent; return swapchain_extent;
} }
else
{
return surface_caps.currentExtent;
}
}
VkSwapchainKHR CreateSwapChain(const DeviceAttribute *dev_attr,const VkExtent2D &extent) VkSwapchainKHR CreateSwapChain(const DeviceAttribute *dev_attr,const VkExtent2D &extent)
{ {