|
30 | 30 |
|
31 | 31 | // CHANGELOG |
32 | 32 | // (minor and older changes stripped away, please see git history for details) |
| 33 | +// 2023-01-02: Vulkan: Removed a bunch of duplicate code. |
33 | 34 | // 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11. |
34 | 35 | // 2022-10-04: Vulkan: Added experimental ImGui_ImplVulkan_RemoveTexture() for api symetry. (#914, #5738). |
35 | 36 | // 2022-01-20: Vulkan: Added support for ImTextureID as VkDescriptorSet. User need to call ImGui_ImplVulkan_AddTexture(). Building for 32-bit targets requires '#define ImTextureID ImU64'. (#914). |
@@ -739,72 +740,6 @@ static void ImGui_ImplVulkan_CreateShaderModules(VkDevice device, const VkAlloca |
739 | 740 | } |
740 | 741 | } |
741 | 742 |
|
742 | | -static void ImGui_ImplVulkan_CreateFontSampler(VkDevice device, const VkAllocationCallbacks* allocator) |
743 | | -{ |
744 | | - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); |
745 | | - if (bd->FontSampler) |
746 | | - return; |
747 | | - |
748 | | - // Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling. |
749 | | - VkSamplerCreateInfo info = {}; |
750 | | - info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
751 | | - info.magFilter = VK_FILTER_LINEAR; |
752 | | - info.minFilter = VK_FILTER_LINEAR; |
753 | | - info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR; |
754 | | - info.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT; |
755 | | - info.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT; |
756 | | - info.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT; |
757 | | - info.minLod = -1000; |
758 | | - info.maxLod = 1000; |
759 | | - info.maxAnisotropy = 1.0f; |
760 | | - VkResult err = vkCreateSampler(device, &info, allocator, &bd->FontSampler); |
761 | | - check_vk_result(err); |
762 | | -} |
763 | | - |
764 | | -static void ImGui_ImplVulkan_CreateDescriptorSetLayout(VkDevice device, const VkAllocationCallbacks* allocator) |
765 | | -{ |
766 | | - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); |
767 | | - if (bd->DescriptorSetLayout) |
768 | | - return; |
769 | | - |
770 | | - ImGui_ImplVulkan_CreateFontSampler(device, allocator); |
771 | | - VkSampler sampler[1] = { bd->FontSampler }; |
772 | | - VkDescriptorSetLayoutBinding binding[1] = {}; |
773 | | - binding[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
774 | | - binding[0].descriptorCount = 1; |
775 | | - binding[0].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; |
776 | | - binding[0].pImmutableSamplers = sampler; |
777 | | - VkDescriptorSetLayoutCreateInfo info = {}; |
778 | | - info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
779 | | - info.bindingCount = 1; |
780 | | - info.pBindings = binding; |
781 | | - VkResult err = vkCreateDescriptorSetLayout(device, &info, allocator, &bd->DescriptorSetLayout); |
782 | | - check_vk_result(err); |
783 | | -} |
784 | | - |
785 | | -static void ImGui_ImplVulkan_CreatePipelineLayout(VkDevice device, const VkAllocationCallbacks* allocator) |
786 | | -{ |
787 | | - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); |
788 | | - if (bd->PipelineLayout) |
789 | | - return; |
790 | | - |
791 | | - // Constants: we are using 'vec2 offset' and 'vec2 scale' instead of a full 3d projection matrix |
792 | | - ImGui_ImplVulkan_CreateDescriptorSetLayout(device, allocator); |
793 | | - VkPushConstantRange push_constants[1] = {}; |
794 | | - push_constants[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
795 | | - push_constants[0].offset = sizeof(float) * 0; |
796 | | - push_constants[0].size = sizeof(float) * 4; |
797 | | - VkDescriptorSetLayout set_layout[1] = { bd->DescriptorSetLayout }; |
798 | | - VkPipelineLayoutCreateInfo layout_info = {}; |
799 | | - layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
800 | | - layout_info.setLayoutCount = 1; |
801 | | - layout_info.pSetLayouts = set_layout; |
802 | | - layout_info.pushConstantRangeCount = 1; |
803 | | - layout_info.pPushConstantRanges = push_constants; |
804 | | - VkResult err = vkCreatePipelineLayout(device, &layout_info, allocator, &bd->PipelineLayout); |
805 | | - check_vk_result(err); |
806 | | -} |
807 | | - |
808 | 743 | static void ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAllocationCallbacks* allocator, VkPipelineCache pipelineCache, VkRenderPass renderPass, VkSampleCountFlagBits MSAASamples, VkPipeline* pipeline, uint32_t subpass) |
809 | 744 | { |
810 | 745 | ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); |
@@ -889,8 +824,6 @@ static void ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAllocationC |
889 | 824 | dynamic_state.dynamicStateCount = (uint32_t)IM_ARRAYSIZE(dynamic_states); |
890 | 825 | dynamic_state.pDynamicStates = dynamic_states; |
891 | 826 |
|
892 | | - ImGui_ImplVulkan_CreatePipelineLayout(device, allocator); |
893 | | - |
894 | 827 | VkGraphicsPipelineCreateInfo info = {}; |
895 | 828 | info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
896 | 829 | info.flags = bd->PipelineCreateFlags; |
@@ -919,6 +852,7 @@ bool ImGui_ImplVulkan_CreateDeviceObjects() |
919 | 852 |
|
920 | 853 | if (!bd->FontSampler) |
921 | 854 | { |
| 855 | + // Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling. |
922 | 856 | VkSamplerCreateInfo info = {}; |
923 | 857 | info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
924 | 858 | info.magFilter = VK_FILTER_LINEAR; |
|
0 commit comments