mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
vulkan: use temporary pipeline cache
This commit is contained in:
@@ -493,6 +493,7 @@ bool Graphics::setMode(void *context, int width, int height, int pixelwidth, int
|
|||||||
createSurface();
|
createSurface();
|
||||||
pickPhysicalDevice();
|
pickPhysicalDevice();
|
||||||
createLogicalDevice();
|
createLogicalDevice();
|
||||||
|
createPipelineCache();
|
||||||
initVMA();
|
initVMA();
|
||||||
initCapabilities();
|
initCapabilities();
|
||||||
createSwapChain();
|
createSwapChain();
|
||||||
@@ -1573,6 +1574,15 @@ void Graphics::createLogicalDevice()
|
|||||||
vkGetDeviceQueue(device, indices.presentFamily.value, 0, &presentQueue);
|
vkGetDeviceQueue(device, indices.presentFamily.value, 0, &presentQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Graphics::createPipelineCache()
|
||||||
|
{
|
||||||
|
VkPipelineCacheCreateInfo cacheInfo{};
|
||||||
|
cacheInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO;
|
||||||
|
|
||||||
|
if (vkCreatePipelineCache(device, &cacheInfo, nullptr, &pipelineCache) != VK_SUCCESS)
|
||||||
|
throw love::Exception("could not create pipeline cache");
|
||||||
|
}
|
||||||
|
|
||||||
void Graphics::initVMA()
|
void Graphics::initVMA()
|
||||||
{
|
{
|
||||||
VmaAllocatorCreateInfo allocatorCreateInfo = {};
|
VmaAllocatorCreateInfo allocatorCreateInfo = {};
|
||||||
@@ -2301,11 +2311,10 @@ void Graphics::setRenderPass(const RenderTargets &rts, int pixelw, int pixelh, b
|
|||||||
false,
|
false,
|
||||||
dynamic_cast<Texture*>(color.texture)->getMsaaSamples() });
|
dynamic_cast<Texture*>(color.texture)->getMsaaSamples() });
|
||||||
if (rts.depthStencil.texture != nullptr)
|
if (rts.depthStencil.texture != nullptr)
|
||||||
if (rts.depthStencil.texture != nullptr)
|
renderPassConfiguration.staticData.depthAttachment = {
|
||||||
renderPassConfiguration.staticData.depthAttachment = {
|
Vulkan::getTextureFormat(rts.depthStencil.texture->getPixelFormat(), false).internalFormat,
|
||||||
Vulkan::getTextureFormat(rts.depthStencil.texture->getPixelFormat(), false).internalFormat,
|
false,
|
||||||
false,
|
dynamic_cast<Texture*>(rts.depthStencil.texture)->getMsaaSamples() };
|
||||||
dynamic_cast<Texture*>(rts.depthStencil.texture)->getMsaaSamples() };
|
|
||||||
|
|
||||||
FramebufferConfiguration configuration{};
|
FramebufferConfiguration configuration{};
|
||||||
|
|
||||||
@@ -2648,7 +2657,7 @@ VkPipeline Graphics::createGraphicsPipeline(GraphicsPipelineConfiguration &confi
|
|||||||
pipelineInfo.renderPass = configuration.renderPass;
|
pipelineInfo.renderPass = configuration.renderPass;
|
||||||
|
|
||||||
VkPipeline graphicsPipeline;
|
VkPipeline graphicsPipeline;
|
||||||
if (vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &graphicsPipeline) != VK_SUCCESS)
|
if (vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineInfo, nullptr, &graphicsPipeline) != VK_SUCCESS)
|
||||||
throw love::Exception("failed to create graphics pipeline");
|
throw love::Exception("failed to create graphics pipeline");
|
||||||
return graphicsPipeline;
|
return graphicsPipeline;
|
||||||
}
|
}
|
||||||
@@ -2934,6 +2943,7 @@ void Graphics::cleanup()
|
|||||||
graphicsPipelines.clear();
|
graphicsPipelines.clear();
|
||||||
|
|
||||||
vkDestroyCommandPool(device, commandPool, nullptr);
|
vkDestroyCommandPool(device, commandPool, nullptr);
|
||||||
|
vkDestroyPipelineCache(device, pipelineCache, nullptr);
|
||||||
vkDestroyDevice(device, nullptr);
|
vkDestroyDevice(device, nullptr);
|
||||||
vkDestroySurfaceKHR(instance, surface, nullptr);
|
vkDestroySurfaceKHR(instance, surface, nullptr);
|
||||||
vkDestroyInstance(instance, nullptr);
|
vkDestroyInstance(instance, nullptr);
|
||||||
|
|||||||
@@ -316,6 +316,7 @@ private:
|
|||||||
int rateDeviceSuitability(VkPhysicalDevice device);
|
int rateDeviceSuitability(VkPhysicalDevice device);
|
||||||
QueueFamilyIndices findQueueFamilies(VkPhysicalDevice device);
|
QueueFamilyIndices findQueueFamilies(VkPhysicalDevice device);
|
||||||
void createLogicalDevice();
|
void createLogicalDevice();
|
||||||
|
void createPipelineCache();
|
||||||
void initVMA();
|
void initVMA();
|
||||||
void createSurface();
|
void createSurface();
|
||||||
bool checkDeviceExtensionSupport(VkPhysicalDevice device);
|
bool checkDeviceExtensionSupport(VkPhysicalDevice device);
|
||||||
@@ -393,6 +394,7 @@ private:
|
|||||||
VkImageView depthImageView = VK_NULL_HANDLE;
|
VkImageView depthImageView = VK_NULL_HANDLE;
|
||||||
VmaAllocation depthImageAllocation = VK_NULL_HANDLE;
|
VmaAllocation depthImageAllocation = VK_NULL_HANDLE;
|
||||||
VkRenderPass defaultRenderPass = VK_NULL_HANDLE;
|
VkRenderPass defaultRenderPass = VK_NULL_HANDLE;
|
||||||
|
VkPipelineCache pipelineCache;
|
||||||
std::vector<VkFramebuffer> defaultFramebuffers;
|
std::vector<VkFramebuffer> defaultFramebuffers;
|
||||||
std::unordered_map<RenderPassConfiguration, VkRenderPass, RenderPassConfigurationHasher> renderPasses;
|
std::unordered_map<RenderPassConfiguration, VkRenderPass, RenderPassConfigurationHasher> renderPasses;
|
||||||
std::unordered_map<FramebufferConfiguration, VkFramebuffer, FramebufferConfigurationHasher> framebuffers;
|
std::unordered_map<FramebufferConfiguration, VkFramebuffer, FramebufferConfigurationHasher> framebuffers;
|
||||||
|
|||||||
Reference in New Issue
Block a user