GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Vulkan: switching between images for rendering by martty · Pull Request #914 · ocornut/imgui

Conversation

@martty

@martty martty commented Nov 15, 2016

Copy link
Copy Markdown
Contributor

As described previously, I implemented ImTextureID with a VkDescriptorSet.

  • I added a utility function for allocating the ImTextureIDs. This allows the user to set both sampler and image(view). Can be removed if not needed. (Note: freeing is not necessary, since the DescriptorSet comes from a pool)
  • Not 100% sure if the cast to void* is legal, someone please correct me if it is not.
  • Let me know if I messed up the formatting!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ratchetfreak

ratchetfreak commented Nov 15, 2016

Copy link
Copy Markdown

non-dispatchable handles (like the vkDescriptorSet) are 64 bit handles. So on 32bit this will create issues.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MrSapps

MrSapps commented Nov 16, 2016

Copy link
Copy Markdown

TextureId appears to be the size of a pointer, so should work

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@martty

martty commented Nov 18, 2016

Copy link
Copy Markdown
Contributor Author

This is what I was afraid of. It is not apparent for me how to best solve this.

We could shove the VkDescriptorSets in an array and hand out indices (+ an indirection to allow deletion).

Or the user could be responsible for management: Put a dynamic array field in the init struct containing the VkDescriptorSets and then ImTextureID is the index into this array. User is responsible for putting the VkDescriptorSets in this array and keeping the ImTextureIDs up to date.

Also there is some difficulty of freeing the DescriptorSets (which I didn't touch in this PR). Maybe the DescriptorPool should be internal, so we can use VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT to free individual Sets, otherwise it will be more difficult to recreate the ones still needed..

Any ideas?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ocornut

ocornut commented Nov 21, 2016

Copy link
Copy Markdown
Owner

Are many people going to use Vulkan in 32-bits?

I could add a #ifndef ImTextureId block to allow overriding that type in imconfig.h, or somehow find a way to reword its declaration so that it would fit 64-bits (not sure how yet), if any useful?

mlknz reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ocornut ocornut added the backends label Nov 21, 2016
@martty

martty commented Nov 21, 2016

Copy link
Copy Markdown
Contributor Author

I think redefining the ImTextureID as unsigned long long (or redefining behind an ifndef if someone wants both Vulkan and 32 bits) would do the trick. As for the first question, I have no idea.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ocornut ocornut mentioned this pull request Oct 16, 2017
GameView Vulkan Impl #1371
Closed
@ocornut

ocornut commented Nov 19, 2017

Copy link
Copy Markdown
Owner

Question to @martty, @ratchetfreak @SaschaWillems @ParticlePeter and other Vulkan users:

Would it perhaps make more sense (and solve this issue) to make ImTextureId a pointer to descriptor set, aka VkDescriptorSet*, instead of the actual structure? Would the user be able to provide pointers to them that would be valid for the frame?

I'm asking because I don't really know the typical lifetime of a VkDescriptorSet nor whether its size is supposed to be opaque.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SaschaWillems

SaschaWillems commented Nov 19, 2017

Copy link
Copy Markdown
Contributor

Not sure about this. A descriptor set contains information beyond what the actual image/texture is about.

Having ImTextureID point to a VkDescriptorSet is something I personally wouldn't do and leave that part to the application. With the change proposed here a ImTextureID would always point to a descriptor set with a fixed image view, fixed image layout (shader read, some ppl. might want to use something else). Fixing the descriptor type to a combined image sampler is also something not everybody may want to use (separating image and sampler is something very common). This would also force the application to allocate such descriptor types when creating the pool.

So IMO I'd prefer the current way with the ImTextureID pointing to VkImage.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ocornut

ocornut commented Nov 19, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Owner

OK, so there are two topics now here. :) Initially Martty suggested VkDescriptorSet and the problem we have at the moment is that ImTextureId is a void* so VkDescriptorSet would NOT fit in a 32-bit app. And I'm hesitant to turn ImTextureId storage into a long long because ImTextureId has already been a huge source of confusion (across all backends) for newer programmers, so I suggested VkDescriptorSet* instead of VkDescriptorSet.

I'd prefer the current way with the ImTextureID pointing to VkImage.

Now you are suggesting to use VkImage. However note that the current backend does NOT support either. It is not the "current way", in fact the render loop currently completely ignore the pcmd->TextureID value making it impossible with the current code to draw other images with ImGui or ImDrawList. So this is what we are aiming at sorting out here!

I'd be happy if you Vulkan users can have that discussion, would be super helpful as I'm not using Vulkan myself yet.
And maybe there isn't a perfect answer. It is semi-expected that people who are building a rendering layer in their engine would eventually replace the render loop. The proposed default is for the Vulkan examples and it's meant to be the "best" reasonable default for Vulkan users who aren't building their own rendering layer.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@martty

martty commented Nov 19, 2017

Copy link
Copy Markdown
Contributor Author

I was really trying to make this change as non-intrusive and user friendly as possible. For users wanting slightly more control can simply make their own ImTextureIDs (adding an extra parameter for layout to AddTexture seems sensible however). Any further would require redoing the shaders, and at that point you could write your own rendering backend. This all being said, I am not against a different implementation.

I'm not sure why putting the VkDescriptorSet simply on the heap didn't occur to me back then, but that could be a solution to the pointer size problem. We should provide a deallocation function then, though.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ocornut

ocornut commented Nov 19, 2017

Copy link
Copy Markdown
Owner

I'm not sure why putting the VkDescriptorSet simply on the heap didn't occur to me back then, but that could be a solution to the pointer size problem. We should provide a deallocation function then, though.

Wouldn't the user already have VkDescriptorSet instances they can just point too?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@martty

martty commented Nov 19, 2017

Copy link
Copy Markdown
Contributor Author

Currently, I made the AddTexture function, which, with the proposed change would do a heap allocation. I think it is reasonable to have a pair function that frees that allocation.

Otherwise, the user can use any pointer to VkDescriptorSet, but allocating & setting a proper VkDescriptorSet requires "inside" knowledge at the moment (the VkDescriptorSetLayout).
(eg. if you meant: would the users reuse their own descriptor sets: they can't)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ocornut
ocornut force-pushed the master branch from edd6a63 to a265837 Compare February 12, 2018 20:44
@ocornut ocornut mentioned this pull request Feb 22, 2018
Looking for feedback/suggestions on changing ImTextureID from void* to u64 #1641
Closed
@meshula

meshula commented Feb 23, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

I went with something similar to @martty 's solution, because one needs to bind an image and sampler to the descriptor set to pass to the cmd within ImGui, and the only ways I thought of to do it, that worked, are to either to do it persistently and pass a descriptor around via the TextureId, or to recreate the descriptor sets on the fly on demand inside of ImGui. I think I understand @SaschaWillems' concern, but it's hard to imagine how to keep ImTexture referring only to a VkImage. My solution was to provide ImGui with a VkImage, and for ImGui to hand me back an ImTexture which is backed by an object that has got the descriptor in it, so that ImGui can manage the sampler and descriptor set persistently on its own. I don't have any expectation that I can unpack the ImTexture and magically use it outside of ImGui.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ocornut ocornut added the vulkan label Mar 1, 2018
@L4zyy L4zyy mentioned this pull request Apr 21, 2018
Load image with Vulkan #1764
Closed
@ocornut ocornut added this to the v1.61 milestone Apr 22, 2018
@ocornut ocornut modified the milestones: v1.61, v1.62 May 14, 2018
@mua

mua commented Jul 29, 2018

Copy link
Copy Markdown

Descriptors worked well for me. I keep descriptors on my texture objects, pass descriptors to ImGui::Image.

test2

meshula, ice1000, Eiyeron, aiekick, Pikachuxxxx, vergeal, loryruta, Yahaha3, and HexagonalUniverse reacted with thumbs up emoji
All reactions
  • 👍 9 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@meshula

meshula commented Jul 29, 2018

Copy link
Copy Markdown

@mua Would you mind posting what you did for comparison with other solutions? It would be great if we could get consensus on a solution and merge it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mua

mua commented Jul 29, 2018

Copy link
Copy Markdown

@meshula I did not want ImGui to persist any resources, I just put descriptor set handle into ImTextureID just like @martty did, bind it in ImGui_ImplVulkan_RenderDrawData. And add a lazy generator for descriptor set on my texture objects. just a method returns guiDescriptorSet if not allocated previously, using the same descriptor set layout as ImGui. So I can tie lifetime of descriptor set to my texture, buffer, image, sampler etc.

meshula reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ocornut ocornut modified the milestones: v1.62, v1.63 Aug 22, 2018
@gviot

gviot commented Sep 2, 2018

Copy link
Copy Markdown

I merged this PR into my own binding (loosely based on the SDL/Vulkan binding). I automatically create the imgui descriptor set (using the ImGui_ImplGlfwVulkan_AddTexture function from the PR) for every texture that I load into my engine because I use imgui to browse the list of all loaded textures anyway.
It works nicely and I didn't care about 32 bits so I used VkDescriptSet as the ImTextureID directly to make things simple.
I don't think using VkDescriptorSet* for everyone as a default would be great because it makes things more complex and potentially even more confusing for newbies. Not sure how to handle it nicely for 32 bits users though.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ocornut ocornut modified the milestones: v1.63, v1.65 Sep 3, 2018
@aCuria

aCuria commented Oct 9, 2018

Copy link
Copy Markdown

Hi,
I am new to imgui, and ran into a problem where passing a VkImage handle to ImGui functions does nothing. Eg: the following code: ImGui::Image(vulkanTexture_.handle(), ImVec2(1000, 1000)); will render the font atlas

I found the following comment in imgui_impl_vulkan.cpp which led me to this post, however there doesnt seem to be a solution explained in this post for newbies yet.
// Missing features:
// [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this binding! See #914

Is there an interim solution I can use before this is fixed in v1.65? (Will it be fixed in 1.65? =x)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dpwiz

dpwiz commented Feb 12, 2022

Copy link
Copy Markdown

Drawing a bunch of images this way can kneecap performance, since each draw will be wrapped in a descset switch.

dear-imgui can have a image descriptor array instead and pass texture IDs in push constants.

layout(set=0, binding=0) { .... generic stuff ... }
layout(set=0, binding=1) uniform sampler2D textures[];

Backend would reserve some DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER descriptors.
Then it can update everything at once, putting all the known textures in there, or issue write in new elements as needed.

Kovenas, jdennis9, Trider12, and n00bmind reacted with thumbs up emoji
All reactions
  • 👍 4 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ghost

ghost commented Feb 17, 2022 •
edited by ghost
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Good point! @dpwiz

Put all textures in an array, then just get the specific texture by index without rebinding, which can improve performance.

But the implementation could be a little complex.

Suppose we need to change textures frequently( sometimes, we just don't know all textures will be used or maybe it will take too many memory to load all textures), then we'll need a way to update the texture array, which might cause the texture index changed for a specific texture.

A possible solution here (Just add an indirect layer):

                                                       +--------------------------------------------------------+
                                                       |                                                        |
                                                       |                                                        |
                                                       |                                                        |
                                                       |                                                        |
                                                       |                                                        |
                                                       |                                                        |
                                                       |                                                        |
                     +--------------------------------------------------+                                +------+--------+
                     |                                 |                |                                |               |
                     |        +-----------+       +----v------+         |                                |   Render ObjX |
raw texture file     |        |           |       |           |         |                                |               |
                     |        |  image 0  |       |  image i  |         |                                +---------------+
                     |        |           |       |           |         |
                     |        +----+------+       +------+----+         |                       ObjX uses texture "image i",
                     |             |                     |              |                       the index of "image i" is dynamic,
                     +--------------------------------------------------+                       we can get it by
                                   |                     |
                                   |    +----------------+                                      getImageTextureIndex("image i")
                                   |    |                    map out of order
                                   +--------------------+                                       Then set the index by pushconstant
                                        |               |
                                        |               |
                                        |               |
                                        |               |
                     +------------------------+-------------------------+
                     |                  |     |         |               |
                     |        +---------v-+   |   +-----v-----+         |
                     |        |           |   |   |           |         |
texture array        |        | texture0  |   |   | texturei  |         |
                     |        |           |   |   |           |         |
                     |        +-----------+   |   +-----------+         |
                     |                        |                         |
                     +------------------------+-------------------------+

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dpwiz

dpwiz commented Feb 17, 2022

Copy link
Copy Markdown

You can treat the texture array as a pool for some texture id slots. Nothing to reinvent here.

Allocate a bunch of "slots", fill in with all the initially known ImageViews (fonts, etc.), add remaining to a free list. Adding a texture would mean picking one slot from the free list and writing a new ImageView to its array index. Evicting a texture is simply returning its index to the free list. Let the texture owner manage its resources.

Also, using image views means you can update the data without updating the descriptor. If you really need to shuttle new image data without blocking to rebuild the descriptor array, just copy your data to the image you've already registered.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@noname-14-pl

noname-14-pl commented Mar 12, 2022

Copy link
Copy Markdown

Someone maybe know when will this be documented in here: https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples ? It would be really helpfull.

Tetane and rytisss reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@1111mp 1111mp mentioned this pull request Mar 14, 2022
How to render Vulkan's scene to ImGui window #5110
Closed
@Pikachuxxxx Pikachuxxxx mentioned this pull request Apr 5, 2022
ImTextureID casting to VkDescriptorSet* is not always FontAtlas set or a valid set #5168
Closed
@ghost

ghost commented Jun 7, 2022

Copy link
Copy Markdown

Good point! @dpwiz

Put all textures in an array, then just get the specific texture by index without rebinding, which can improve performance.

But the implementation could be a little complex.

Suppose we need to change textures frequently( sometimes, we just don't know all textures will be used or maybe it will take too many memory to load all textures), then we'll need a way to update the texture array, which might cause the texture index changed for a specific texture.

A possible solution here (Just add an indirect layer):

                                                       +--------------------------------------------------------+
                                                       |                                                        |
                                                       |                                                        |
                                                       |                                                        |
                                                       |                                                        |
                                                       |                                                        |
                                                       |                                                        |
                                                       |                                                        |
                     +--------------------------------------------------+                                +------+--------+
                     |                                 |                |                                |               |
                     |        +-----------+       +----v------+         |                                |   Render ObjX |
raw texture file     |        |           |       |           |         |                                |               |
                     |        |  image 0  |       |  image i  |         |                                +---------------+
                     |        |           |       |           |         |
                     |        +----+------+       +------+----+         |                       ObjX uses texture "image i",
                     |             |                     |              |                       the index of "image i" is dynamic,
                     +--------------------------------------------------+                       we can get it by
                                   |                     |
                                   |    +----------------+                                      getImageTextureIndex("image i")
                                   |    |                    map out of order
                                   +--------------------+                                       Then set the index by pushconstant
                                        |               |
                                        |               |
                                        |               |
                                        |               |
                     +------------------------+-------------------------+
                     |                  |     |         |               |
                     |        +---------v-+   |   +-----v-----+         |
                     |        |           |   |   |           |         |
texture array        |        | texture0  |   |   | texturei  |         |
                     |        |           |   |   |           |         |
                     |        +-----------+   |   +-----------+         |
                     |                        |                         |
                     +------------------------+-------------------------+

Just like using some tech like descriptor indexing to get a unbound descriptor set, and it's easy to update this set async safe, i think it is a good idea for imgui texture binding.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ocornut

ocornut commented Jul 5, 2022

Copy link
Copy Markdown
Owner

Although likely to be a bit bulky, it would be nice if someone could add an example for loading textures in Vulkan in this Wiki page: https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples

rytisss, TheLavaBlock, tlf30, and ppyht2 reacted with heart emoji
All reactions
  • ❤️ 4 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rytisss rytisss mentioned this pull request Jul 23, 2022
Vulkan Backend image rendering. Image sampler always 'REPEAT' #5502
Closed
@timprepscius

timprepscius commented Jul 29, 2022

Copy link
Copy Markdown

Hey there, I'm reading through this and the vulkan backend code, this question probably has a super obvious answer but, here goes:

I see calls to vkAllocateDescriptorSets, and I get they are allocated from pools.
When are those pools freed? Is it per frame?

Do I need to worry about descriptor sets reaching some maximum?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DangitBen

DangitBen commented Sep 8, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Although likely to be a bit bulky, it would be nice if someone could add an example for loading textures in Vulkan in this Wiki page: https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples

As @ocornut, @rolandhill, and @Chomiczjakub asked, I have added an example to the above page for Vulkan after struggling with this for a while. I am far from a Vulkan/ImGui expert, so if someone would be willing to look it over for any egregious errors/malpractice I would appreciate it. If anyone wants to test it out, that would be great too!

I made some assumptions for the sake of "brevity":

  • A starting point is one of the vulkan example files (uses g_Device, g_Allocator, g_MainWindowData, g_PhysicalDevice, and check_vk_result()).
  • It is acceptable to use one of the command pools from the g_MainWindowData.
  • User is responsible for cleaning up/destroying any Vulkan objects in a proper implementation.
dpwiz reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@CarloWood

CarloWood commented Sep 12, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Thanks to @DangitBen for taking the effort. I definitely thought about writing up such an example, but Vulkan is just too bulky. In my opinion it wasn't possible to write something self-contained without falling into the same pitfall that every other tutorial on vulkan out there has fallen into: you can't use their code without being severely limited - even making grave mistakes in terms of real-life code (ie, baking into the example a 1:1 relationship between two objects that doesn't exist). A beginner, when using such code as a base for their own code almost MUST run into serious problems later on when they try to do something that is more real-life, more practical (e.g. try to write an actual game). For example, I could not use my own code to show how to upload a texture to the GPU - because that is useless without using my vulkan engine. And it is not possible to rip out those parts of the engine that are being used and include them in the example-- vulkan is just too darn complex.

PS Here is code that I use to upload a texture:

      vk_utils::stbi::ImageData texture_data(m_application->path_of(Directory::resources) / "textures/vort3_128x128.png", 4);
      // Create descriptor resources.
      { 
        static vulkan::ImageKind const sample_image_kind({
          .format = vk::Format::eR8G8B8A8Unorm,
          .usage = vk::ImageUsageFlagBits::eTransferDst | vk::ImageUsageFlagBits::eSampled
        });
  
        static vulkan::ImageViewKind const sample_image_view_kind(sample_image_kind, {});

        m_sample_texture = vulkan::shader_resource::Texture("vort3", m_logical_device,
            texture_data.extent(), sample_image_view_kind,
            { .mipmapMode = vk::SamplerMipmapMode::eNearest,
              .anisotropyEnable = VK_FALSE },
            graphics_settings(),
            { .properties = vk::MemoryPropertyFlagBits::eDeviceLocal }
            COMMA_CWDEBUG_ONLY(debug_name_prefix("m_sample_texture")));
     
        auto copy_data_to_image = statefultask::create<task::CopyDataToImage>(m_logical_device, texture_data.size(),
            m_sample_texture.m_vh_image, texture_data.extent(), vk_defaults::ImageSubresourceRange{},
            vk::ImageLayout::eUndefined, vk::AccessFlags(0), vk::PipelineStageFlagBits::eTopOfPipe,
            vk::ImageLayout::eShaderReadOnlyOptimal, vk::AccessFlagBits::eShaderRead, vk::PipelineStageFlagBits::eFragmentShader
            COMMA_CWDEBUG_ONLY(true));
  
        copy_data_to_image->set_resource_owner(this);   // Wait for this task to finish before destroying this window, because this window owns the texture (m_sample_texture).
        copy_data_to_image->set_data_feeder(std::make_unique<vk_utils::stbi::ImageDataFeeder>(std::move(texture_data)));
        copy_data_to_image->run(vulkan::Application::instance().low_priority_queue());
      }
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ocornut ocornut mentioned this pull request Oct 3, 2022
Provide an API to free texture descritpors allocated by Vulkan backend #5738
Closed
ocornut added a commit that referenced this pull request Oct 4, 2022
@ocornut
Backends: Vulkan: Added experimental ImGui_ImplVulkan_RemoveTexture()…
a588f00
… for api symetry. (#914, #5738).
@ocornut

ocornut commented Oct 4, 2022

Copy link
Copy Markdown
Owner

Today added ImGui_ImplVulkan_RemoveTexture() for api symmetry a588f00

@DangitBen Thanks for a lot for this addition to the tutorial. I confirmed it works on my side, but realized using LoadTextureFromFile() as provided would lead to debug layer emitting leak info on exit.

Do you think you or someone) could refactor this?

(1) Bundling all data into a structure e.g.

struct MyTextureData
{
    VkDescriptorSet DS;         // Descriptor set: this is what you'll pass to Image()
    int             Width;
    int             Height;
    // + missing fields

    MyTextureData() { memset(this, 0, sizeof(*this)); }
};

Aptly named this way to emphasis this is an example and likely not a base for more advanced stuff, but I'm also sure some casual users will be happy using this as it so it is nice if it's usable as it.

(2) Adding a RemoveTexture(MyTextureData*) in the example freeing all the right Vulkan objects (include a call to newly added ImGui_ImplVulkan_RemoveTexture()` but more stuff needs to be done).

Aim being that example should be able to exit without any report from debug layer.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ocornut added a commit that referenced this pull request Oct 4, 2022
@ocornut
Backends: Vulkan: Fix building with VK_NO_PROTOTYPES. (#914, #5738).
282b2b5
Amend a588f00
@DangitBen

DangitBen commented Nov 10, 2022

Copy link
Copy Markdown

I confirmed it works on my side, but realized using LoadTextureFromFile() as provided would lead to debug layer emitting leak info on exit.

Yeah I did call this out in my comment above, but not in such specific language.

Do you think you or someone) could refactor this?

@ocornut done! While I am not certain about what the lifetime of the objects should be, the validation layers seem to be silent and happy now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ocornut ocornut reopened this Nov 10, 2022
@ocornut

ocornut commented Nov 15, 2022

Copy link
Copy Markdown
Owner

@DangitBen Thank you for updating the wiki!
https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ocornut ocornut closed this Nov 15, 2022
ocornut pushed a commit that referenced this pull request Jan 2, 2023
@martin-ejdestig @ocornut
Backends; Vulkan: do not set VkDescriptorSetLayoutBinding::pImmutable…
e5d5186
…Samplers, allow changing sampler. (#6001, #5502, #914)

Follow up to c9aef16 which removec three funtions worth of duplicate code.
@PowerOfNames PowerOfNames mentioned this pull request Jan 19, 2023
Understanding of ImTextureID management/maybe bug in context with Vulkan DescriptorSets #6098
Closed
@ocornut ocornut mentioned this pull request Jul 29, 2023
Fix Vulkan examples descriptor pool setup #6642
Closed
@Nemirtingas

Nemirtingas commented Aug 9, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Hi, instead of the ImGui_ImplVulkan_AddTexture/ImGui_ImplVulkan_RemoveTexture, you could do something analogous to DirectX12, where you send the CPU and GPU handles, and passing a VkDescriptorSet in the init function?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Marlax0 Marlax0 mentioned this pull request Feb 12, 2025
Add support for user images to ImGui integration of SampleBase NVIDIA-RTX/NRIFramework#9
Closed
maztheman pushed a commit to maztheman/imgui that referenced this pull request Mar 10, 2025
@martin-ejdestig MazTheMan
Backends; Vulkan: do not set VkDescriptorSetLayoutBinding::pImmutable…
5e887e3
…Samplers, allow changing sampler. (ocornut#6001, ocornut#5502, ocornut#914)

Follow up to c9aef16 which removec three funtions worth of duplicate code.
@maverikou maverikou mentioned this pull request Sep 22, 2025
Implement VK_KHR_push_descriptor support for the Vulkan backend #8954
Closed
ocornut pushed a commit that referenced this pull request Apr 22, 2026
@yaz0r @ocornut
(Breaking) Backends: Vulkan: redesigned to use separate ImageView + S…
0453ae9
…ampler instead of Combined Image Sampler. (WIP) (#914)
ocornut added a commit that referenced this pull request Apr 22, 2026
@ocornut
(Breaking) Backends: Vulkan: redesigned to use separate ImageView + S…
ac26120
…ampler instead of Combined Image Sampler. (fixes, amends) (#914)
ocornut added a commit that referenced this pull request Apr 22, 2026
@ocornut
Remove noise from 0453ae9 + amend comments. (#914)
fb308c1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

backends vulkan

Projects

None yet

Milestone

v1.88

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

20 participants

@martty @ratchetfreak @MrSapps @ocornut @SaschaWillems @meshula @mua @gviot @aCuria @hanatos @lordalcol @johannesugb @Ybalrid @figwig @sirus20x6 @cklosters @temportalflux @electromaggot @fknfilewalker @warriormaster12
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.