diff --git a/example/Vulkan/Deferred.cpp b/example/Vulkan/Deferred.cpp index 6748bfa6..53f35467 100644 --- a/example/Vulkan/Deferred.cpp +++ b/example/Vulkan/Deferred.cpp @@ -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; diff --git a/example/Vulkan/HQFilterTexture.cpp b/example/Vulkan/HQFilterTexture.cpp index e2b1514d..e0c185ca 100644 --- a/example/Vulkan/HQFilterTexture.cpp +++ b/example/Vulkan/HQFilterTexture.cpp @@ -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; diff --git a/example/Vulkan/TGATexture.cpp b/example/Vulkan/TGATexture.cpp index 307422fe..85b4c1e9 100644 --- a/example/Vulkan/TGATexture.cpp +++ b/example/Vulkan/TGATexture.cpp @@ -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 diff --git a/inc/hgl/graph/vulkan/VKDevice.h b/inc/hgl/graph/vulkan/VKDevice.h index f6629db6..c6459fde 100644 --- a/inc/hgl/graph/vulkan/VKDevice.h +++ b/inc/hgl/graph/vulkan/VKDevice.h @@ -25,7 +25,7 @@ class Device bool CreateSwapchainColorTexture(); bool CreateSwapchainDepthTexture(); - Swapchain *CreateSwapchain(const VkExtent2D &acquire_extent); + bool CreateSwapchain(const VkExtent2D &acquire_extent); private: diff --git a/src/RenderDevice/Vulkan/VKDevice.cpp b/src/RenderDevice/Vulkan/VKDevice.cpp index d05371dc..03f57376 100644 --- a/src/RenderDevice/Vulkan/VKDevice.cpp +++ b/src/RenderDevice/Vulkan/VKDevice.cpp @@ -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); diff --git a/src/RenderDevice/Vulkan/VKDeviceSwapchain.cpp b/src/RenderDevice/Vulkan/VKDeviceSwapchain.cpp index 9b48a3a6..14aad40f 100644 --- a/src/RenderDevice/Vulkan/VKDeviceSwapchain.cpp +++ b/src/RenderDevice/Vulkan/VKDeviceSwapchain.cpp @@ -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 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 diff --git a/src/RenderDevice/Vulkan/VKDeviceTexture.cpp b/src/RenderDevice/Vulkan/VKDeviceTexture.cpp index a4f80d08..ed3ebcb1 100644 --- a/src/RenderDevice/Vulkan/VKDeviceTexture.cpp +++ b/src/RenderDevice/Vulkan/VKDeviceTexture.cpp @@ -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)