mirror of https://github.com/AxioDL/boo.git
More Vulkan fixes
This commit is contained in:
parent
3197142d1f
commit
71593afe50
|
@ -702,6 +702,7 @@ struct VulkanPool : IGraphicsBufferPool
|
|||
{
|
||||
VkDeviceMemory m_bufMem = VK_NULL_HANDLE;
|
||||
std::unique_ptr<class VulkanGraphicsBufferD> m_buffer;
|
||||
bool m_dead = false;
|
||||
Buffer(VkDeviceMemory mem, class VulkanGraphicsBufferD* buf)
|
||||
: m_bufMem(mem), m_buffer(buf) {}
|
||||
};
|
||||
|
@ -714,6 +715,21 @@ struct VulkanPool : IGraphicsBufferPool
|
|||
if (buf.second.m_bufMem)
|
||||
vk::FreeMemory(m_ctx->m_dev, buf.second.m_bufMem, nullptr);
|
||||
}
|
||||
|
||||
void clearDeadBuffers()
|
||||
{
|
||||
for (auto it = m_DBufs.begin() ; it != m_DBufs.end() ;)
|
||||
{
|
||||
if (it->second.m_dead)
|
||||
{
|
||||
if (it->second.m_bufMem)
|
||||
vk::FreeMemory(m_ctx->m_dev, it->second.m_bufMem, nullptr);
|
||||
it = m_DBufs.erase(it);
|
||||
continue;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static const VkBufferUsageFlagBits USE_TABLE[] =
|
||||
|
@ -3264,7 +3280,9 @@ IGraphicsBufferD* VulkanDataFactory::newPoolBuffer(IGraphicsBufferPool* p, Buffe
|
|||
void VulkanDataFactory::deletePoolBuffer(IGraphicsBufferPool* p, IGraphicsBufferD* buf)
|
||||
{
|
||||
VulkanPool* pool = static_cast<VulkanPool*>(p);
|
||||
pool->m_DBufs.erase(static_cast<VulkanGraphicsBufferD*>(buf));
|
||||
auto search = pool->m_DBufs.find(static_cast<VulkanGraphicsBufferD*>(buf));
|
||||
if (search != pool->m_DBufs.end())
|
||||
search->second.m_dead = true;
|
||||
}
|
||||
|
||||
GraphicsBufferPoolToken VulkanDataFactory::newBufferPool()
|
||||
|
@ -3357,6 +3375,10 @@ void VulkanCommandQueue::execute()
|
|||
delete p;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*it)->clearDeadBuffers();
|
||||
}
|
||||
++it;
|
||||
}
|
||||
datalk.unlock();
|
||||
|
|
|
@ -393,7 +393,7 @@ struct GraphicsContextWin32Vulkan : GraphicsContextWin32
|
|||
HWND m_hwnd;
|
||||
VulkanContext* m_ctx;
|
||||
VkSurfaceKHR m_surface = VK_NULL_HANDLE;
|
||||
VkFormat m_format;
|
||||
VkFormat m_format = VK_FORMAT_UNDEFINED;
|
||||
VkColorSpaceKHR m_colorspace;
|
||||
uint32_t m_sampleCount;
|
||||
|
||||
|
@ -577,15 +577,23 @@ public:
|
|||
* supported format will be returned. */
|
||||
if (formatCount >= 1)
|
||||
{
|
||||
if (surfFormats[0].format == VK_FORMAT_UNDEFINED)
|
||||
m_format = VK_FORMAT_B8G8R8A8_UNORM;
|
||||
else
|
||||
m_format = surfFormats[0].format;
|
||||
m_colorspace = surfFormats[0].colorSpace;
|
||||
for (int i=0 ; i<formatCount ; ++i)
|
||||
{
|
||||
if (surfFormats[i].format == VK_FORMAT_B8G8R8A8_UNORM ||
|
||||
surfFormats[i].format == VK_FORMAT_R8G8B8A8_UNORM)
|
||||
{
|
||||
m_format = surfFormats[i].format;
|
||||
m_colorspace = surfFormats[i].colorSpace;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
Log.report(logvisor::Fatal, "no surface formats available for Vulkan swapchain");
|
||||
|
||||
if (m_format == VK_FORMAT_UNDEFINED)
|
||||
Log.report(logvisor::Fatal, "no UNORM formats available for Vulkan swapchain");
|
||||
|
||||
m_ctx->initSwapChain(*m_windowCtx, m_surface, m_format, m_colorspace);
|
||||
|
||||
m_dataFactory = new class VulkanDataFactory(this, m_ctx, m_sampleCount);
|
||||
|
|
|
@ -763,15 +763,23 @@ public:
|
|||
* supported format will be returned. */
|
||||
if (formatCount >= 1)
|
||||
{
|
||||
if (surfFormats[0].format == VK_FORMAT_UNDEFINED)
|
||||
m_format = VK_FORMAT_B8G8R8A8_UNORM;
|
||||
else
|
||||
m_format = surfFormats[0].format;
|
||||
m_colorspace = surfFormats[0].colorSpace;
|
||||
for (int i=0 ; i<formatCount ; ++i)
|
||||
{
|
||||
if (surfFormats[i].format == VK_FORMAT_B8G8R8A8_UNORM ||
|
||||
surfFormats[i].format == VK_FORMAT_R8G8B8A8_UNORM)
|
||||
{
|
||||
m_format = surfFormats[i].format;
|
||||
m_colorspace = surfFormats[i].colorSpace;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
Log.report(logvisor::Fatal, "no surface formats available for Vulkan swapchain");
|
||||
|
||||
if (m_format == VK_FORMAT_UNDEFINED)
|
||||
Log.report(logvisor::Fatal, "no UNORM formats available for Vulkan swapchain");
|
||||
|
||||
m_ctx->initSwapChain(*m_windowCtx, m_surface, m_format, m_colorspace);
|
||||
|
||||
/* Spawn vsync thread */
|
||||
|
|
Loading…
Reference in New Issue