GeezerVison is showing github.com — WebGPU ImGui::Image not accepts different texture formats · Issue #7592 · ocornut/imgui
WebGPU ImGui::Image not accepts different texture formats #7592
Description
Version/Branch of Dear ImGui:
Version 1.90.6, Branch: master
Back-ends:
imgui_impl_wgpu.cpp + imgui_impl_glfw.cpp
Compiler, OS:
macOS + Clang 17.0.6
Full config/build information:
No response
Details:
My Issue/Question:
I stumbled upon issue which when I directly attempt to display depth texture of the render pass through ImGui::Image program stops with below error, presumably due to sampler mismatch when Image tries to bind Depth texture as an WGPUTextureSampleType_Float format instead of WGPUTextureSampleType_Depth and I wonder if it's an design decision or missing feature? since being not able to set or specify the texture format for Image leads to introduce some manual labor on the users side such as converting different texture formats to WGPUTextureSampleType_Float through an additional pass.
Error:
WGPU error: None of the supported sample types (UnfilterableFloat|Depth) of [Texture (unlabeled 3840x2160 px, TextureFormat::Depth32Float)] match the expected sample
types (Float).
- While validating entries[0] as a Sampled Texture.
Expected entry layout: {sampleType: TextureSampleType::Float, viewDimension: 2, multisampled: 0}
- While validating [BindGroupDescriptor] against [BindGroupLayout (unlabeled)]
- While calling [Device "My Device"].CreateBindGroup([BindGroupDescriptor]).
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
WGPUTextureDescriptor depthTextureDesc = {};
depthTextureDesc.dimension = WGPUTextureDimension_2D;
depthTextureDesc.format = WGPUTextureFormat_Depth32Float;
depthTextureDesc.mipLevelCount = 1;
depthTextureDesc.sampleCount = 1;
depthTextureDesc.size.width = width;
depthTextureDesc.size.height = height;
depthTextureDesc.size.depthOrArrayLayers = 1;
// Create shadowDepth texture ...
// Create shadowDepthview ...
ImGui::Image((ImTextureID)shadowDepthView, ImVec2(size.x, size.y));Activity
ocornut commented on May 15, 2024
This is a topic that applies to every backends.
Generally the suggested solution (e.g. #3590) is to use a AddCallback() drawcmd to manually make the render change sampler or other render state. Note how e.g. #7511 or #6908 would lead to same direction.
Now, whether this is easy or even possible might depends on the backend and how to alter that render state.
For some backends user code may lack access to backend internal data and we may need a solution for that.
I think you should dig in WGPU backend and see if you can find a way to implement this via draw callbacks.
Generally I think we ought to find solution to make some common case easier (e.g. switch from linear to point filtering).
#2697 essentially proposed making user able to rewire texture binding code while using standard backends which is probably a desirable eventually but would drag a bunch of other things, as user code may need more standardized access to some backend internal data.
PhantomCloak commented on May 16, 2024
ContributorAuthor
More actions
Thanks for the clarification. I agree this not might be easy since problem is tricky to solve in a backend agnostic way which is case for WebGPU too due to lack of api to determine texture state after creation but I will look draw callbacks and what can I do. I close this issue due to there is already plenty of discussions about similar points.
ocornut commented on May 16, 2024
The general idea is:
- try to solve it with callbacks
- if something is in your way to be able to solve it with callbacks, please discuss specifics and we can discuss modifying backend accordingly.
ocornut commented on Oct 8, 2024
The changes discussed in #6969 (comment) should make this easier nowadays. happy to work together on populating whatever extra data struct ImGui_ImplWGPU_RenderState may need.
Metadata
Metadata
Development
No branches or pull requestsIssue actions