修复至可运行

This commit is contained in:
hyzboy 2019-11-26 00:33:24 +08:00
parent f5cafb91b8
commit 338558205e
7 changed files with 21 additions and 20 deletions

View File

@ -16,7 +16,7 @@ using namespace hgl;
using namespace hgl::graph;
VK_NAMESPACE_BEGIN
Texture2D *LoadTGATexture(const OSString &filename,Device *device);
Texture2D *LoadTGATexture(const OSString &filename,Device *device,bool use_optimal=true);
VK_NAMESPACE_END
constexpr uint32_t SCREEN_WIDTH=256;

View File

@ -10,7 +10,7 @@ using namespace hgl;
using namespace hgl::graph;
VK_NAMESPACE_BEGIN
Texture2D *LoadTGATexture(const OSString &filename,Device *device);
Texture2D *LoadTGATexture(const OSString &filename,Device *device,bool use_optimal=true);
VK_NAMESPACE_END
constexpr uint32_t SCREEN_WIDTH=512;

View File

@ -255,7 +255,7 @@ Texture2D *LoadTGATexture(const OSString &filename,Device *device,bool use_optim
if(use_optimar)
{
device->CreateTexture2D(format,buf,header.width,header.height);
tex=device->CreateTexture2D(format,buf,header.width,header.height);
delete buf;
}
else

View File

@ -25,7 +25,7 @@ class Device
bool CreateSwapchainColorTexture();
bool CreateSwapchainDepthTexture();
Swapchain *CreateSwapchain(const VkExtent2D &acquire_extent);
bool CreateSwapchain(const VkExtent2D &acquire_extent);
private:

View File

@ -43,7 +43,9 @@ bool Device::Resize(const VkExtent2D &extent)
SAFE_CLEAR(texture_cmd_buf);
attr->Refresh();
swapchain=CreateSwapchain(extent);
if(!CreateSwapchain(extent))
return(false);
texture_cmd_buf=CreateCommandBuffer(extent,0);
textureSQ=new SubmitQueue(this,attr->graphics_queue,1);

View File

@ -118,24 +118,23 @@ bool Device::CreateSwapchainDepthTexture()
return swapchain->sc_depth;
}
Swapchain *Device::CreateSwapchain(const VkExtent2D &acquire_extent)
bool Device::CreateSwapchain(const VkExtent2D &acquire_extent)
{
AutoDelete<Swapchain> sc=new Swapchain;
swapchain=new Swapchain;
sc->device =attr->device;
sc->extent =SwapchainExtentClamp(attr->surface_caps,acquire_extent);
sc->graphics_queue =attr->graphics_queue;
sc->swap_chain =CreateSwapChain(attr,sc->extent);
swapchain->device =attr->device;
swapchain->extent =SwapchainExtentClamp(attr->surface_caps,acquire_extent);
swapchain->graphics_queue =attr->graphics_queue;
swapchain->swap_chain =CreateSwapChain(attr,swapchain->extent);
if(!sc->swap_chain)
return(nullptr);
if(swapchain->swap_chain)
if(CreateSwapchainColorTexture())
if(CreateSwapchainDepthTexture())
return(true);
if(!CreateSwapchainColorTexture())
return(nullptr);
delete swapchain;
swapchain=nullptr;
if(!CreateSwapchainDepthTexture())
return(nullptr);
return sc.Finish();
return(false);
}
VK_NAMESPACE_END

View File

@ -92,7 +92,7 @@ Texture2D *Device::CreateTexture2D(const VkFormat format,uint32_t width,uint32_t
ImageView *iv=CreateImageView2D(attr->device,format,ext,aspectMask,img);
return CreateTexture2D(format,width,height,aspectMask,usage,image_layout,linear);
return CreateTexture2D(mem,img,iv,image_layout,linear);
}
Texture2D *Device::CreateTexture2D(const VkFormat format,Buffer *buf,uint32_t width,uint32_t height,const VkImageAspectFlags aspectMask,const uint usage,const VkImageLayout image_layout,const bool linear)