|
|
|
|
@@ -269,7 +269,8 @@ struct ImGui_ImplVulkan_Data
|
|
|
|
|
VkDeviceSize BufferMemoryAlignment;
|
|
|
|
|
VkDeviceSize NonCoherentAtomSize;
|
|
|
|
|
VkPipelineCreateFlags PipelineCreateFlags;
|
|
|
|
|
VkDescriptorSetLayout DescriptorSetLayout;
|
|
|
|
|
VkDescriptorSetLayout DescriptorSetLayoutTexture;
|
|
|
|
|
VkDescriptorSetLayout DescriptorSetLayoutSampler;
|
|
|
|
|
VkPipelineLayout PipelineLayout;
|
|
|
|
|
VkPipeline Pipeline; // pipeline for main render pass (created by app)
|
|
|
|
|
VkShaderModule ShaderModuleVert;
|
|
|
|
|
@@ -279,6 +280,9 @@ struct ImGui_ImplVulkan_Data
|
|
|
|
|
|
|
|
|
|
// Texture management
|
|
|
|
|
VkSampler SamplerLinear;
|
|
|
|
|
VkSampler SamplerNearest;
|
|
|
|
|
VkDescriptorSet SamplerLinearDS;
|
|
|
|
|
VkDescriptorSet SamplerNearestDS;
|
|
|
|
|
VkCommandPool TexCommandPool;
|
|
|
|
|
VkCommandBuffer TexCommandBuffer;
|
|
|
|
|
|
|
|
|
|
@@ -375,30 +379,34 @@ void main()
|
|
|
|
|
*/
|
|
|
|
|
static uint32_t __glsl_shader_frag_spv[] =
|
|
|
|
|
{
|
|
|
|
|
0x07230203,0x00010000,0x00080001,0x0000001e,0x00000000,0x00020011,0x00000001,0x0006000b,
|
|
|
|
|
0x07230203,0x00010000,0x0008000b,0x00000023,0x00000000,0x00020011,0x00000001,0x0006000b,
|
|
|
|
|
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
|
|
|
|
|
0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000009,0x0000000d,0x00030010,
|
|
|
|
|
0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,
|
|
|
|
|
0x00000000,0x00040005,0x00000009,0x6c6f4366,0x0000726f,0x00030005,0x0000000b,0x00000000,
|
|
|
|
|
0x00050006,0x0000000b,0x00000000,0x6f6c6f43,0x00000072,0x00040006,0x0000000b,0x00000001,
|
|
|
|
|
0x00005655,0x00030005,0x0000000d,0x00006e49,0x00050005,0x00000016,0x78655473,0x65727574,
|
|
|
|
|
0x00000000,0x00040047,0x00000009,0x0000001e,0x00000000,0x00040047,0x0000000d,0x0000001e,
|
|
|
|
|
0x00000000,0x00040047,0x00000016,0x00000022,0x00000000,0x00040047,0x00000016,0x00000021,
|
|
|
|
|
0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,
|
|
|
|
|
0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040020,0x00000008,0x00000003,
|
|
|
|
|
0x00000007,0x0004003b,0x00000008,0x00000009,0x00000003,0x00040017,0x0000000a,0x00000006,
|
|
|
|
|
0x00000002,0x0004001e,0x0000000b,0x00000007,0x0000000a,0x00040020,0x0000000c,0x00000001,
|
|
|
|
|
0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000001,0x00040015,0x0000000e,0x00000020,
|
|
|
|
|
0x00000001,0x0004002b,0x0000000e,0x0000000f,0x00000000,0x00040020,0x00000010,0x00000001,
|
|
|
|
|
0x00000007,0x00090019,0x00000013,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,
|
|
|
|
|
0x00000001,0x00000000,0x0003001b,0x00000014,0x00000013,0x00040020,0x00000015,0x00000000,
|
|
|
|
|
0x00000014,0x0004003b,0x00000015,0x00000016,0x00000000,0x0004002b,0x0000000e,0x00000018,
|
|
|
|
|
0x00000001,0x00040020,0x00000019,0x00000001,0x0000000a,0x00050036,0x00000002,0x00000004,
|
|
|
|
|
0x00000000,0x00000003,0x000200f8,0x00000005,0x00050041,0x00000010,0x00000011,0x0000000d,
|
|
|
|
|
0x0000000f,0x0004003d,0x00000007,0x00000012,0x00000011,0x0004003d,0x00000014,0x00000017,
|
|
|
|
|
0x00000016,0x00050041,0x00000019,0x0000001a,0x0000000d,0x00000018,0x0004003d,0x0000000a,
|
|
|
|
|
0x0000001b,0x0000001a,0x00050057,0x00000007,0x0000001c,0x00000017,0x0000001b,0x00050085,
|
|
|
|
|
0x00000007,0x0000001d,0x00000012,0x0000001c,0x0003003e,0x00000009,0x0000001d,0x000100fd,
|
|
|
|
|
0x00005655,0x00030005,0x0000000d,0x00006e49,0x00050005,0x00000015,0x7865545f,0x65727574,
|
|
|
|
|
0x00000000,0x00050005,0x00000019,0x6d61535f,0x72656c70,0x00000000,0x00040047,0x00000009,
|
|
|
|
|
0x0000001e,0x00000000,0x00040047,0x0000000d,0x0000001e,0x00000000,0x00040047,0x00000015,
|
|
|
|
|
0x00000022,0x00000000,0x00040047,0x00000015,0x00000021,0x00000000,0x00040047,0x00000019,
|
|
|
|
|
0x00000022,0x00000001,0x00040047,0x00000019,0x00000021,0x00000000,0x00020013,0x00000002,
|
|
|
|
|
0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,
|
|
|
|
|
0x00000006,0x00000004,0x00040020,0x00000008,0x00000003,0x00000007,0x0004003b,0x00000008,
|
|
|
|
|
0x00000009,0x00000003,0x00040017,0x0000000a,0x00000006,0x00000002,0x0004001e,0x0000000b,
|
|
|
|
|
0x00000007,0x0000000a,0x00040020,0x0000000c,0x00000001,0x0000000b,0x0004003b,0x0000000c,
|
|
|
|
|
0x0000000d,0x00000001,0x00040015,0x0000000e,0x00000020,0x00000001,0x0004002b,0x0000000e,
|
|
|
|
|
0x0000000f,0x00000000,0x00040020,0x00000010,0x00000001,0x00000007,0x00090019,0x00000013,
|
|
|
|
|
0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x00040020,
|
|
|
|
|
0x00000014,0x00000000,0x00000013,0x0004003b,0x00000014,0x00000015,0x00000000,0x0002001a,
|
|
|
|
|
0x00000017,0x00040020,0x00000018,0x00000000,0x00000017,0x0004003b,0x00000018,0x00000019,
|
|
|
|
|
0x00000000,0x0003001b,0x0000001b,0x00000013,0x0004002b,0x0000000e,0x0000001d,0x00000001,
|
|
|
|
|
0x00040020,0x0000001e,0x00000001,0x0000000a,0x00050036,0x00000002,0x00000004,0x00000000,
|
|
|
|
|
0x00000003,0x000200f8,0x00000005,0x00050041,0x00000010,0x00000011,0x0000000d,0x0000000f,
|
|
|
|
|
0x0004003d,0x00000007,0x00000012,0x00000011,0x0004003d,0x00000013,0x00000016,0x00000015,
|
|
|
|
|
0x0004003d,0x00000017,0x0000001a,0x00000019,0x00050056,0x0000001b,0x0000001c,0x00000016,
|
|
|
|
|
0x0000001a,0x00050041,0x0000001e,0x0000001f,0x0000000d,0x0000001d,0x0004003d,0x0000000a,
|
|
|
|
|
0x00000020,0x0000001f,0x00050057,0x00000007,0x00000021,0x0000001c,0x00000020,0x00050085,
|
|
|
|
|
0x00000007,0x00000022,0x00000012,0x00000021,0x0003003e,0x00000009,0x00000022,0x000100fd,
|
|
|
|
|
0x00010038
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@@ -510,6 +518,9 @@ static void ImGui_ImplVulkan_SetupRenderState(ImDrawData* draw_data, VkPipeline
|
|
|
|
|
constants[2] = -1.0f - draw_data->DisplayPos.x * constants[0]; // Translate
|
|
|
|
|
constants[3] = -1.0f - draw_data->DisplayPos.y * constants[1];
|
|
|
|
|
vkCmdPushConstants(command_buffer, bd->PipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(float) * 4, constants);
|
|
|
|
|
|
|
|
|
|
// use linear sampler by default
|
|
|
|
|
vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, bd->PipelineLayout, 1, 1, &bd->SamplerLinearDS, 0, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Render function
|
|
|
|
|
@@ -618,6 +629,16 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|
|
|
|
pcmd->UserCallback(draw_list, pcmd);
|
|
|
|
|
last_desc_set = VK_NULL_HANDLE;
|
|
|
|
|
}
|
|
|
|
|
/*else if (pcmd->UserCallback == ImDrawCallback_SetSamplerLinear)
|
|
|
|
|
{ // Bind Sampler
|
|
|
|
|
vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, bd->PipelineLayout, 1, 1, &bd->SamplerLinearDS, 0, nullptr);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (pcmd->UserCallback == ImDrawCallback_SetSamplerNearest)
|
|
|
|
|
{
|
|
|
|
|
// Bind Sampler
|
|
|
|
|
vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, bd->PipelineLayout, 1, 1, &bd->SamplerNearestDS, 0, nullptr);
|
|
|
|
|
}*/
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Project scissor/clipping rectangles into framebuffer space
|
|
|
|
|
@@ -747,7 +768,7 @@ void ImGui_ImplVulkan_UpdateTexture(ImTextureData* tex)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create the Descriptor Set
|
|
|
|
|
backend_tex->DescriptorSet = ImGui_ImplVulkan_AddTexture(bd->SamplerLinear, backend_tex->ImageView, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
|
|
|
|
backend_tex->DescriptorSet = ImGui_ImplVulkan_AddTexture(backend_tex->ImageView, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
|
|
|
|
|
|
|
|
|
// Store identifiers
|
|
|
|
|
tex->SetTexID((ImTextureID)backend_tex->DescriptorSet);
|
|
|
|
|
@@ -1065,12 +1086,40 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
|
|
|
|
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
|
|
|
|
VkResult err;
|
|
|
|
|
|
|
|
|
|
if (!bd->DescriptorSetLayout)
|
|
|
|
|
ImGui_ImplVulkan_CreateDescriptorSetLayout(&bd->DescriptorSetLayout, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER);
|
|
|
|
|
if (!bd->DescriptorSetLayoutTexture)
|
|
|
|
|
{
|
|
|
|
|
VkDescriptorSetLayoutBinding binding[1] = {};
|
|
|
|
|
binding[0].binding = 0;
|
|
|
|
|
binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
|
|
|
|
|
binding[0].descriptorCount = 1;
|
|
|
|
|
binding[0].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
|
|
|
|
VkDescriptorSetLayoutCreateInfo info = {};
|
|
|
|
|
info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
|
|
|
|
info.bindingCount = 1;
|
|
|
|
|
info.pBindings = binding;
|
|
|
|
|
err = vkCreateDescriptorSetLayout(v->Device, &info, v->Allocator, &bd->DescriptorSetLayoutTexture);
|
|
|
|
|
check_vk_result(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!bd->DescriptorSetLayoutSampler)
|
|
|
|
|
{
|
|
|
|
|
VkDescriptorSetLayoutBinding binding[1] = {};
|
|
|
|
|
binding[0].binding = 0;
|
|
|
|
|
binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER;
|
|
|
|
|
binding[0].descriptorCount = 1;
|
|
|
|
|
binding[0].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
|
|
|
|
VkDescriptorSetLayoutCreateInfo info = {};
|
|
|
|
|
info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
|
|
|
|
info.bindingCount = 1;
|
|
|
|
|
info.pBindings = binding;
|
|
|
|
|
err = vkCreateDescriptorSetLayout(v->Device, &info, v->Allocator, &bd->DescriptorSetLayoutSampler);
|
|
|
|
|
check_vk_result(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (v->DescriptorPoolSize != 0)
|
|
|
|
|
{
|
|
|
|
|
IM_ASSERT(v->DescriptorPoolSize >= IMGUI_IMPL_VULKAN_MINIMUM_IMAGE_SAMPLER_POOL_SIZE);
|
|
|
|
|
// TODO: need to account for the samplers too
|
|
|
|
|
IM_ASSERT(v->DescriptorPoolSize >= IMGUI_IMPL_VULKAN_MINIMUM_IMAGE_POOL_SIZE);
|
|
|
|
|
VkDescriptorPoolSize pool_size = { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, v->DescriptorPoolSize };
|
|
|
|
|
VkDescriptorPoolCreateInfo pool_info = {};
|
|
|
|
|
pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
|
|
|
|
@@ -1082,10 +1131,9 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
|
|
|
|
|
check_vk_result(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create sampler
|
|
|
|
|
// Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling.
|
|
|
|
|
if (!bd->SamplerLinear)
|
|
|
|
|
{
|
|
|
|
|
// Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling.
|
|
|
|
|
VkSamplerCreateInfo info = {};
|
|
|
|
|
info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
|
|
|
|
info.magFilter = VK_FILTER_LINEAR;
|
|
|
|
|
@@ -1101,6 +1149,87 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
|
|
|
|
|
check_vk_result(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!bd->SamplerNearest)
|
|
|
|
|
{
|
|
|
|
|
VkSamplerCreateInfo info = {};
|
|
|
|
|
info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
|
|
|
|
info.magFilter = VK_FILTER_NEAREST;
|
|
|
|
|
info.minFilter = VK_FILTER_NEAREST;
|
|
|
|
|
info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST;
|
|
|
|
|
info.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
|
|
|
|
info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
|
|
|
|
info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
|
|
|
|
info.minLod = -1000;
|
|
|
|
|
info.maxLod = 1000;
|
|
|
|
|
info.maxAnisotropy = 1.0f;
|
|
|
|
|
err = vkCreateSampler(v->Device, &info, v->Allocator, &bd->SamplerNearest);
|
|
|
|
|
check_vk_result(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!bd->SamplerLinearDS)
|
|
|
|
|
{
|
|
|
|
|
VkDescriptorPool pool = bd->DescriptorPool ? bd->DescriptorPool : v->DescriptorPool;
|
|
|
|
|
|
|
|
|
|
// Create Descriptor Set:
|
|
|
|
|
VkDescriptorSet descriptor_set;
|
|
|
|
|
{
|
|
|
|
|
VkDescriptorSetAllocateInfo alloc_info = {};
|
|
|
|
|
alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
|
|
|
|
alloc_info.descriptorPool = pool;
|
|
|
|
|
alloc_info.descriptorSetCount = 1;
|
|
|
|
|
alloc_info.pSetLayouts = &bd->DescriptorSetLayoutSampler;
|
|
|
|
|
VkResult err = vkAllocateDescriptorSets(v->Device, &alloc_info, &descriptor_set);
|
|
|
|
|
check_vk_result(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update the Descriptor Set:
|
|
|
|
|
{
|
|
|
|
|
VkDescriptorImageInfo desc_image[1] = {};
|
|
|
|
|
desc_image[0].sampler = bd->SamplerLinear;
|
|
|
|
|
VkWriteDescriptorSet sampler_write_desc[1] = {};
|
|
|
|
|
sampler_write_desc[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
|
|
|
|
sampler_write_desc[0].dstSet = descriptor_set;
|
|
|
|
|
sampler_write_desc[0].descriptorCount = 1;
|
|
|
|
|
sampler_write_desc[0].dstBinding = 0;
|
|
|
|
|
sampler_write_desc[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER;
|
|
|
|
|
sampler_write_desc[0].pImageInfo = desc_image;
|
|
|
|
|
vkUpdateDescriptorSets(v->Device, 1, sampler_write_desc, 0, nullptr);
|
|
|
|
|
}
|
|
|
|
|
bd->SamplerLinearDS = descriptor_set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!bd->SamplerNearestDS)
|
|
|
|
|
{
|
|
|
|
|
VkDescriptorPool pool = bd->DescriptorPool ? bd->DescriptorPool : v->DescriptorPool;
|
|
|
|
|
|
|
|
|
|
// Create Descriptor Set:
|
|
|
|
|
VkDescriptorSet descriptor_set;
|
|
|
|
|
{
|
|
|
|
|
VkDescriptorSetAllocateInfo alloc_info = {};
|
|
|
|
|
alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
|
|
|
|
alloc_info.descriptorPool = pool;
|
|
|
|
|
alloc_info.descriptorSetCount = 1;
|
|
|
|
|
alloc_info.pSetLayouts = &bd->DescriptorSetLayoutSampler;
|
|
|
|
|
VkResult err = vkAllocateDescriptorSets(v->Device, &alloc_info, &descriptor_set);
|
|
|
|
|
check_vk_result(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update the Descriptor Set:
|
|
|
|
|
{
|
|
|
|
|
VkDescriptorImageInfo desc_image[1] = {};
|
|
|
|
|
desc_image[0].sampler = bd->SamplerNearest;
|
|
|
|
|
VkWriteDescriptorSet sampler_write_desc[1] = {};
|
|
|
|
|
sampler_write_desc[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
|
|
|
|
sampler_write_desc[0].dstSet = descriptor_set;
|
|
|
|
|
sampler_write_desc[0].descriptorCount = 1;
|
|
|
|
|
sampler_write_desc[0].dstBinding = 0;
|
|
|
|
|
sampler_write_desc[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER;
|
|
|
|
|
sampler_write_desc[0].pImageInfo = desc_image;
|
|
|
|
|
vkUpdateDescriptorSets(v->Device, 1, sampler_write_desc, 0, nullptr);
|
|
|
|
|
}
|
|
|
|
|
bd->SamplerNearestDS = descriptor_set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!bd->PipelineLayout)
|
|
|
|
|
{
|
|
|
|
|
// Constants: we are using 'vec2 offset' and 'vec2 scale' instead of a full 3d projection matrix
|
|
|
|
|
@@ -1108,10 +1237,10 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
|
|
|
|
|
push_constants[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
|
|
|
|
push_constants[0].offset = sizeof(float) * 0;
|
|
|
|
|
push_constants[0].size = sizeof(float) * 4;
|
|
|
|
|
VkDescriptorSetLayout set_layout[1] = { bd->DescriptorSetLayout };
|
|
|
|
|
VkDescriptorSetLayout set_layout[2] = { bd->DescriptorSetLayoutTexture, bd->DescriptorSetLayoutSampler };
|
|
|
|
|
VkPipelineLayoutCreateInfo layout_info = {};
|
|
|
|
|
layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
|
|
|
|
layout_info.setLayoutCount = 1;
|
|
|
|
|
layout_info.setLayoutCount = 2;
|
|
|
|
|
layout_info.pSetLayouts = set_layout;
|
|
|
|
|
layout_info.pushConstantRangeCount = 1;
|
|
|
|
|
layout_info.pPushConstantRanges = push_constants;
|
|
|
|
|
@@ -1192,9 +1321,11 @@ void ImGui_ImplVulkan_DestroyDeviceObjects()
|
|
|
|
|
if (bd->TexCommandBuffer) { vkFreeCommandBuffers(v->Device, bd->TexCommandPool, 1, &bd->TexCommandBuffer); bd->TexCommandBuffer = VK_NULL_HANDLE; }
|
|
|
|
|
if (bd->TexCommandPool) { vkDestroyCommandPool(v->Device, bd->TexCommandPool, v->Allocator); bd->TexCommandPool = VK_NULL_HANDLE; }
|
|
|
|
|
if (bd->SamplerLinear) { vkDestroySampler(v->Device, bd->SamplerLinear, v->Allocator); bd->SamplerLinear = VK_NULL_HANDLE; }
|
|
|
|
|
if (bd->SamplerNearest) { vkDestroySampler(v->Device, bd->SamplerNearest, v->Allocator); bd->SamplerNearest = VK_NULL_HANDLE; }
|
|
|
|
|
if (bd->ShaderModuleVert) { vkDestroyShaderModule(v->Device, bd->ShaderModuleVert, v->Allocator); bd->ShaderModuleVert = VK_NULL_HANDLE; }
|
|
|
|
|
if (bd->ShaderModuleFrag) { vkDestroyShaderModule(v->Device, bd->ShaderModuleFrag, v->Allocator); bd->ShaderModuleFrag = VK_NULL_HANDLE; }
|
|
|
|
|
if (bd->DescriptorSetLayout) { vkDestroyDescriptorSetLayout(v->Device, bd->DescriptorSetLayout, v->Allocator); bd->DescriptorSetLayout = VK_NULL_HANDLE; }
|
|
|
|
|
if (bd->DescriptorSetLayoutTexture) { vkDestroyDescriptorSetLayout(v->Device, bd->DescriptorSetLayoutTexture, v->Allocator); bd->DescriptorSetLayoutTexture = VK_NULL_HANDLE; }
|
|
|
|
|
if (bd->DescriptorSetLayoutSampler) { vkDestroyDescriptorSetLayout(v->Device, bd->DescriptorSetLayoutSampler, v->Allocator); bd->DescriptorSetLayoutSampler = VK_NULL_HANDLE; }
|
|
|
|
|
if (bd->PipelineLayout) { vkDestroyPipelineLayout(v->Device, bd->PipelineLayout, v->Allocator); bd->PipelineLayout = VK_NULL_HANDLE; }
|
|
|
|
|
if (bd->Pipeline) { vkDestroyPipeline(v->Device, bd->Pipeline, v->Allocator); bd->Pipeline = VK_NULL_HANDLE; }
|
|
|
|
|
if (bd->DescriptorPool) { vkDestroyDescriptorPool(v->Device, bd->DescriptorPool, v->Allocator); bd->DescriptorPool = VK_NULL_HANDLE; }
|
|
|
|
|
@@ -1355,7 +1486,7 @@ void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count)
|
|
|
|
|
|
|
|
|
|
// Register a texture by creating a descriptor
|
|
|
|
|
// FIXME: This is experimental in the sense that we are unsure how to best design/tackle this problem, please post to https://github.com/ocornut/imgui/pull/914 if you have suggestions.
|
|
|
|
|
VkDescriptorSet ImGui_ImplVulkan_AddTexture(VkSampler sampler, VkImageView image_view, VkImageLayout image_layout)
|
|
|
|
|
VkDescriptorSet ImGui_ImplVulkan_AddTexture(VkImageView image_view, VkImageLayout image_layout)
|
|
|
|
|
{
|
|
|
|
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
|
|
|
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
|
|
|
|
@@ -1368,7 +1499,7 @@ VkDescriptorSet ImGui_ImplVulkan_AddTexture(VkSampler sampler, VkImageView image
|
|
|
|
|
alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
|
|
|
|
alloc_info.descriptorPool = pool;
|
|
|
|
|
alloc_info.descriptorSetCount = 1;
|
|
|
|
|
alloc_info.pSetLayouts = &bd->DescriptorSetLayout;
|
|
|
|
|
alloc_info.pSetLayouts = &bd->DescriptorSetLayoutTexture;
|
|
|
|
|
VkResult err = vkAllocateDescriptorSets(v->Device, &alloc_info, &descriptor_set);
|
|
|
|
|
check_vk_result(err);
|
|
|
|
|
}
|
|
|
|
|
@@ -1377,14 +1508,13 @@ VkDescriptorSet ImGui_ImplVulkan_AddTexture(VkSampler sampler, VkImageView image
|
|
|
|
|
if (descriptor_set != VK_NULL_HANDLE)
|
|
|
|
|
{
|
|
|
|
|
VkDescriptorImageInfo desc_image[1] = {};
|
|
|
|
|
desc_image[0].sampler = sampler;
|
|
|
|
|
desc_image[0].imageView = image_view;
|
|
|
|
|
desc_image[0].imageLayout = image_layout;
|
|
|
|
|
VkWriteDescriptorSet write_desc[1] = {};
|
|
|
|
|
write_desc[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
|
|
|
|
write_desc[0].dstSet = descriptor_set;
|
|
|
|
|
write_desc[0].descriptorCount = 1;
|
|
|
|
|
write_desc[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
|
|
|
|
write_desc[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
|
|
|
|
|
write_desc[0].pImageInfo = desc_image;
|
|
|
|
|
vkUpdateDescriptorSets(v->Device, 1, write_desc, 0, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|