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 — WebGPU ImGui::Image not accepts different texture formats · Issue #7592 · ocornut/imgui

WebGPU ImGui::Image not accepts different texture formats #7592

New issue
Copy link
New issue
Copy link
Closed
Closed
WebGPU ImGui::Image not accepts different texture formats#7592
Copy link
Labels
backendsdrawing/drawlistwebemscripten, wgpu etc.

Description

@PhantomCloak
PhantomCloak
opened on May 15, 2024
Issue body actions

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

  1. ocornut
    added
    backends
    webemscripten, wgpu etc.
    drawing/drawlist
    on May 15, 2024
  2. ocornut commented on May 15, 2024

    @ocornut
    ocornut
    on May 15, 2024
    Owner
    More actions

    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.

  3. PhantomCloak commented on May 16, 2024

    @PhantomCloak
    PhantomCloak
    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.

  4. PhantomCloak
    closed this as completedon May 16, 2024
  5. ocornut commented on May 16, 2024

    @ocornut
    ocornut
    on May 16, 2024
    Owner
    More actions

    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.
    Reacted by PhantomCloak
  6. ocornut commented on Oct 8, 2024

    @ocornut
    ocornut
    on Oct 8, 2024
    Owner
    More actions

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendsdrawing/drawlistwebemscripten, wgpu etc.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.