X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbackends%2Fvulkan%2Fpipelinecache.cpp;h=052ce37ffa5e2e738c65d9d706ce59516d2b5a33;hb=370eb9e;hp=8cc447aedbf91c2bf8f68cb302483637d2aaaa8a;hpb=7d83470885ed35852c15568bd56ece1a638b2670;p=libs%2Fgl.git diff --git a/source/backends/vulkan/pipelinecache.cpp b/source/backends/vulkan/pipelinecache.cpp index 8cc447ae..052ce37f 100644 --- a/source/backends/vulkan/pipelinecache.cpp +++ b/source/backends/vulkan/pipelinecache.cpp @@ -15,23 +15,7 @@ namespace GL { PipelineCache::PipelineCache(Device &d): device(d) -{ - const VulkanFunctions &vk = device.get_functions(); - - VkDescriptorPoolSize pool_sizes[2] = { }; - pool_sizes[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; - pool_sizes[0].descriptorCount = 10000; - pool_sizes[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; - pool_sizes[1].descriptorCount = 10000; - - VkDescriptorPoolCreateInfo pool_info = { }; - pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; - pool_info.maxSets = 10000; - pool_info.poolSizeCount = 2; - pool_info.pPoolSizes = pool_sizes; - - vk.CreateDescriptorPool(pool_info, descriptor_pool); -} +{ } PipelineCache::~PipelineCache() { @@ -41,7 +25,6 @@ PipelineCache::~PipelineCache() vk.DestroyRenderPass(kvp.second); for(const auto &kvp: pipelines) vk.DestroyPipeline(kvp.second); - vk.DestroyDescriptorPool(descriptor_pool); } VkRenderPass PipelineCache::get_render_pass(const FrameFormat &format, bool clear, bool discard, bool to_present) @@ -76,7 +59,7 @@ VkRenderPass PipelineCache::get_render_pass(const FrameFormat &format, bool clea 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 = (clear ? VK_IMAGE_LAYOUT_UNDEFINED : external_layout); + attachments[i].initialLayout = ((clear && discard) ? VK_IMAGE_LAYOUT_UNDEFINED : external_layout); attachments[i].finalLayout = external_layout; if(subpass_layout==VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) @@ -150,38 +133,5 @@ VkPipeline PipelineCache::get_pipeline(const PipelineState &ps) return pipeline; } -VkDescriptorSet PipelineCache::get_descriptor_set(const PipelineState &ps, unsigned index) -{ - const VulkanFunctions &vk = device.get_functions(); - - uint64_t key = ps.compute_descriptor_set_hash(index); - auto i = descriptor_sets.find(key); - if(i!=descriptor_sets.end()) - return i->second; - - VkDescriptorSetLayout layout = ps.get_descriptor_set_layout(index); - - VkDescriptorSetAllocateInfo alloc_info = { }; - alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; - alloc_info.descriptorPool = handle_cast<::VkDescriptorPool>(descriptor_pool); - alloc_info.descriptorSetCount = 1; - alloc_info.pSetLayouts = handle_cast<::VkDescriptorSetLayout *>(&layout); - - VkDescriptorSet desc_set; - vk.AllocateDescriptorSets(alloc_info, &desc_set); - - vector buffer; - unsigned n_writes = ps.fill_descriptor_writes(index, buffer); - VkWriteDescriptorSet *writes = reinterpret_cast(buffer.data()); - for(unsigned j=0; j(desc_set); - - vk.UpdateDescriptorSets(n_writes, writes, 0, 0); - - descriptor_sets.insert(make_pair(key, desc_set)); - - return desc_set; -} - } // namespace GL } // namespace Msp