Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font descriptor set of the backend is always null #7458

Open
Carcodee opened this issue Mar 31, 2024 · 0 comments
Open

Font descriptor set of the backend is always null #7458

Carcodee opened this issue Mar 31, 2024 · 0 comments

Comments

@Carcodee
Copy link

Version/Branch of Dear ImGui:

Version 1.90.3, Branch: docking

Back-ends:

imgui_impl_Vulkan.cpp + imgui_impl_glfwcpp

Compiler, OS:

Windows 11, Visual Studio

Full config/build information:

No response

Details:

When I try to run the Imgui in my vulkan engine its giving me this validation error:

validation layer: Validation Error: [ VUID-vkCmdBindDescriptorSets-pDescriptorSets-06563 ] Object 0: handle = 0x2299b662f70, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x747d089 | vkCmdBindDescriptorSets(): pDescriptorSets[0] (VkDescriptorSet 0x0[]) that does not exist, and the layout was not created VK_PIPELINE_LAYOUT_CREATE_INDEPENDENT_SETS_BIT_EXT. The Vulkan spec states: If graphicsPipelineLibrary is not enabled, each element of pDescriptorSets must be a valid VkDescriptorSet (https://vulkan.lunarg.com/doc/view/1.3.280.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdBindDescriptorSets-pDescriptorSets-06563)

-However, this drawcall is being called from the renderdrawdata, which is using a descriptor set created in the back end. I was looking if I missing something in my initialization of Imgui but I don't find anything that is related to that descriptor set.
-This is the line int the renderdrawdata that is causing the validation error:

` VkDescriptorSet desc_set[1] = { (VkDescriptorSet)pcmd->TextureId };
if (sizeof(ImTextureID) < sizeof(ImU64))
{
// We don't support texture switches if ImTextureID hasn't been redefined to be 64-bit. Do a flaky check that other textures haven't been used.
IM_ASSERT(pcmd->TextureId == (ImTextureID)bd->FontDescriptorSet);
desc_set[0] = bd->FontDescriptorSet;
}
vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, bd->PipelineLayout, 0, 1, desc_set, 0, nullptr);

`

  • This is my initialization:

` void VulkanApp::SetUpImgui()
{

    VkDescriptorPoolSize pool_sizes[] =
    {
        { VK_DESCRIPTOR_TYPE_SAMPLER, 1000 },
        { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1000 },
        { VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1000 },
        { VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1000 },
        { VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1000 },
        { VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1000 },
        { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1000 },
        { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1000 },
        { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1000 },
        { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1000 },
        { VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1000 }
    };

    VkDescriptorPoolCreateInfo pool_info = {};
    pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
    pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
    pool_info.maxSets = 1000;
    pool_info.poolSizeCount = std::size(pool_sizes);
    pool_info.pPoolSizes = pool_sizes;

    VkDescriptorPool imguiPool;
    (vkCreateDescriptorPool(myDevice.device(), &pool_info, nullptr, &imguiPool));

    // Setup Dear ImGui context
    IMGUI_CHECKVERSION();
    ImGui::CreateContext();
    ImGuiIO& io = ImGui::GetIO(); (void)io;
    io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;     // Enable Keyboard Controls
    io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;      // Enable Gamepad Controls
    io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;         // Enable Docking
    //io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;       // Enable Multi-Viewport / Platform Windows

    //io.ConfigViewportsNoAutoMerge = true;
    //io.ConfigViewportsNoTaskBarIcon = true;
    ImGuiStyle& style = ImGui::GetStyle();
    if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
    {
        style.WindowRounding = 0.0f;
        style.Colors[ImGuiCol_WindowBg].w = 1.0f;
    }
    io.Fonts->AddFontDefault();
    // Our state
    bool show_demo_window = true;
    bool show_another_window = false;
    ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
    // Setup Dear ImGui style

    io.DisplaySize = ImVec2(800, 600); // Set to actual window size
    ImGui::StyleColorsDark();

    // Setup Platform/Renderer backends
    bool result = ImGui_ImplGlfw_InitForVulkan(initWindow.window, true);
    if (result)
    {
        std::cout << "Imgui window init success" << "\n";
    }
    ImGui_ImplVulkan_InitInfo init_info = {};
    init_info.Instance = VULKAN::MyVulkanDevice::g_Instance;
    init_info.PhysicalDevice = VULKAN::MyVulkanDevice::g_PhysicalDevice;
    init_info.Device = VULKAN::MyVulkanDevice::g_Device;
    init_info.QueueFamily = VULKAN::MyVulkanDevice::g_QueueFamily;
    init_info.Queue = VULKAN::MyVulkanDevice::g_Queue;
    init_info.PipelineCache = VULKAN::MyVulkanDevice::g_PipelineCache;
    init_info.DescriptorPool = imguiPool;
    init_info.RenderPass = renderer.GetSwapchainRenderPass();
    init_info.Subpass = 0;
    init_info.MinImageCount = VULKAN::MyVulkanDevice::g_MinImageCount;
    init_info.ImageCount = renderer.GetImageCount();
    init_info.MSAASamples = myDevice.msaaSamples;
    init_info.Allocator = VULKAN::MyVulkanDevice::g_Allocator;
    init_info.CheckVkResultFn = check_vk_result;
    ImGui_ImplVulkan_Init(&init_info);
    std::cout << "Hello Editor" << std::endl;
    ImGui_ImplVulkan_CreateFontsTexture();

}`

-This is my render loop

` void VulkanApp::Run()
{
while (!initWindow.ShouldClose())
{
glfwPollEvents();
int currentTime = glfwGetTime();

		static auto newTime = std::chrono::high_resolution_clock::now();
		auto d = std::chrono::high_resolution_clock::now();
		float time = std::chrono::duration<float, std::chrono::seconds::period>(d - newTime).count();


		if (auto commandBuffer = renderer.BeginComputeFrame())
		{


			forward_RS.TransitionBeforeComputeRender(renderer.GetCurrentFrame());

			if (cicles==3)
			{
				VkImageSubresourceRange imageSubresourceRange = {};
				imageSubresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
				imageSubresourceRange.baseMipLevel = 0;
				imageSubresourceRange.levelCount = 1; // Clear only one mip level
				imageSubresourceRange.baseArrayLayer = 0;
				imageSubresourceRange.layerCount = 1; // Assuming the image is not an array
				const VkClearColorValue clearValue = { 0.0f, 0.0f, 0.0f, 0.0f };
				vkCmdClearColorImage(commandBuffer, forward_RS.outputStorageImage->textureImage, VK_IMAGE_LAYOUT_GENERAL,&clearValue, 1,&imageSubresourceRange);
				cicles = 0;
			}
			forward_RS.CreateComputeWorkGroups(renderer.GetCurrentFrame(), commandBuffer);
			forward_RS.UpdateUBO(renderer.GetCurrentFrame(), time);
			renderer.EndComputeFrame();
		}
		if (auto commandBuffer = renderer.BeginFrame())
		{
			forward_RS.TransitionBeforeForwardRender(renderer.GetCurrentFrame());	
			renderer.BeginSwapChainRenderPass(commandBuffer);
			forward_RS.pipelineReader->bind(commandBuffer);
			forward_RS.renderSystemDescriptorSetHandler->UpdateUniformBuffer<UniformBufferObjectData>(renderer.GetCurrentFrame(), 1);

			//vkCmdDraw(commandBuffer[imageIndex], 3, 1, 0, 0);
			myModel->BindVertexBufferIndexed(commandBuffer);
			myModel->BindDescriptorSet(commandBuffer, forward_RS.pipelineLayout,forward_RS.renderSystemDescriptorSetHandler->descriptorData[0].descriptorSets[renderer.GetCurrentFrame()]);
			myModel->DrawIndexed(commandBuffer);
			//TEST----


			ImGui_ImplVulkan_NewFrame();
			ImGui_ImplGlfw_NewFrame();
			ImGui::NewFrame();
			bool showDemoWindow = true;
			if (true)
			    ImGui::ShowDemoWindow(&showDemoWindow);

			ImGui::Render();
			ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), commandBuffer, 0);

			//TEST---------------------

			renderer.EndSwapChainRenderPass(commandBuffer);
			renderer.EndFrame();
		}
		deltaTime = (currentTime - lastDeltaTime) * 100.0;
		lastDeltaTime = currentTime;
		cicles++;
	}

	//TEST
	ImGui_ImplVulkan_Shutdown();

	ImGui_ImplGlfw_Shutdown();
	ImGui::DestroyContext();

	vkDeviceWaitIdle(myDevice.device());
}`

Screenshots/Video:

This is what it looks like (no fonts basically):
Screenshot 2024-03-30 224353

Minimal, Complete and Verifiable Example code:

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants