-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Vulkan Backend image rendering. Image sampler always 'REPEAT' #5502
Comments
Hi, @rytisss @ocornut But in vulkan spec, when pImmutableSamplers no NULL, pipeline will default use these init sampler and never dynamic switch sampler. So the resolve method is just keep pImmutableSamplers is NULL like this: |
Hi @qiutanguu , Line commented ( imgui/backends/imgui_impl_vulkan.cpp Line 972 in 8cbd391
|
It would be good to find a solution that doesn’t requires making a modification to the backend otherwise you aren’t going to easily update your copy. this may need to be designed into a backend change. |
Indeed, totally agree. This is just a temporary fix. I will reopen the issue. Maybe someone who is more experienced in Vulkan backend could give a suggestion if it is the proper way of solving this issue. |
I think that is all there is to it, pImmutableSamplers just needs to not be set. From https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkDescriptorSetLayoutBinding.html :
(There are two vkCreateDescriptorSetLayout() calls though. Not sure why. Should be removed in both places, I think.) |
Just a a note, but I think I also met this problem. In my case have not noticed any visual issues, but when I show buttons with custom Texture in them, Vulkan validation layers will show an error:
Dropping the setting of pImmutableSamplers in backend fixes the validation error, and I have so far not noticed any problems with that. |
From https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkDescriptorSetLayoutBinding.html : "pImmutableSamplers affects initialization of samplers. If descriptorType specifies a VK_DESCRIPTOR_TYPE_SAMPLER or VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER type descriptor, then pImmutableSamplers can be used to initialize a set of immutable samplers. Immutable samplers are permanently bound into the set layout and must not be changed; updating a VK_DESCRIPTOR_TYPE_SAMPLER descriptor with immutable samplers is not allowed and updates to a VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER descriptor with immutable samplers does not modify the samplers (the image views are updated, but the sampler updates are ignored)." So setting it means the same sampler will be used for all textures, basically making sampler argument to ImGui_ImplVulkan_AddTexture() useless. Fixes ocornut#5502 .
Merged fix e5d5186. Thanks a lot @martin-ejdestig and @rytisss! |
I have changed all samplers to default to clamp: 42206b3 |
Version/Branch of Dear ImGui:
Version: 1.88
Branch: docking
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_vulkan.cpp
Compiler: Visual Studio C++ 2022
Operating System: Windows 10
I have a problem with texture visualization, I am trying to visualize the texture (picture) and clamp the image to the border. However, as much as I try to change the parameters in the sampler, I still get the repetitive pattern:
The code for the sampler:
Even when
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER
orVK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE
is set, the results are the same (see image above). It seems that sampling is all the timeVK_SAMPLER_ADDRESS_MODE_REPEAT
.To create a descriptor set (
VkDescriptorSet
), I am using:m_descriptorSet = ImGui_ImplVulkan_AddTexture(m_textureSampler, m_textureImageView, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
And to add an image:
It is sampling outside of image regions (outside should be with defined color), however, I get repetitive image patterns all the time (similar to repeat sampling mode).
I am wondering if there are any options set by default in the ImGui Vulkan backend that might interfere with this texture sampling (or override it)? Any help and hints are appreciated!
Might be related to #914
The text was updated successfully, but these errors were encountered: