]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/vulkan/pipelinecache.cpp
Treat clear() with null parameter as invalidate
[libs/gl.git] / source / backends / vulkan / pipelinecache.cpp
index e24c72dbba4944dc6f3180b61af8557f6ac0a8ec..3f8e55008223484036b3e5c4760ae5c5bd09d047 100644 (file)
@@ -44,11 +44,11 @@ PipelineCache::~PipelineCache()
        vk.DestroyDescriptorPool(descriptor_pool);
 }
 
-VkRenderPass PipelineCache::get_render_pass(const FrameFormat &format, bool is_cleared, bool to_present)
+VkRenderPass PipelineCache::get_render_pass(const FrameFormat &format, bool clear, bool discard, bool to_present)
 {
        const VulkanFunctions &vk = device.get_functions();
 
-       uint64_t key = hash<64>(static_cast<uint8_t>(is_cleared | (to_present*2)));
+       uint64_t key = hash<64>(static_cast<uint8_t>(clear | (discard*2) | (to_present*4)));
        for(FrameAttachment a: format)
                key = hash_update<64>(key, a);
 
@@ -69,11 +69,11 @@ VkRenderPass PipelineCache::get_render_pass(const FrameFormat &format, bool is_c
        {
                attachments[i].format = static_cast<VkFormat>(get_vulkan_pixelformat(get_attachment_pixelformat(a)));
                attachments[i].samples = vk_samples;
-               attachments[i].loadOp = (is_cleared ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_LOAD);
+               attachments[i].loadOp = (clear ? discard ? VK_ATTACHMENT_LOAD_OP_DONT_CARE : VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_LOAD);
                attachments[i].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
                attachments[i].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
                attachments[i].stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
-               attachments[i].initialLayout = (is_cleared ? VK_IMAGE_LAYOUT_UNDEFINED : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
+               attachments[i].initialLayout = (clear ? VK_IMAGE_LAYOUT_UNDEFINED : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
                attachments[i].finalLayout = (to_present ? VK_IMAGE_LAYOUT_PRESENT_SRC_KHR : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
 
                unsigned attach_pt = get_attach_point(a);