Skip to content

ImguiWgpuBackend._update_texture: want_create upload uses update_rect instead of full texture size #811

Description

@ro0o0o0okie

imgui_backend.py

_update_texture uses tex.update_rect.w / h as the write extent for want_create, but update_rect only covers modified regions, not the whole texture. The GPU texture ends up partially uninitialized — CJK fonts show missing glyphs with demo window enabled, and all glyphs disappear when tex_glyph_padding is left at default (1).

The bug:

# imgui_backend.py L157-165
if tex.status == imgui.ImTextureStatus.want_create:
    upload_x = 0
    upload_y = 0
else:
    upload_x = tex.update_rect.x
    upload_y = tex.update_rect.y

upload_w = tex.update_rect.w   # should be tex.width for want_create
upload_h = tex.update_rect.h   # should be tex.height

C++ reference (imgui_impl_wgpu.cpp):

const int upload_w = (tex->Status == ImTextureStatus_WantCreate) ? tex->Width  : tex->UpdateRect.w;
const int upload_h = (tex->Status == ImTextureStatus_WantCreate) ? tex->Height : tex->UpdateRect.h;

The GPU texture is created at tex.width × tex.height , so the upload should match that. Fix is straightforward: use tex.width / tex.height for want_create.

Proposed fix

  -        upload_w = tex.update_rect.w
  -        upload_h = tex.update_rect.h
  +        if tex.status == imgui.ImTextureStatus.want_create:
  +            upload_w = tex.width
  +            upload_h = tex.height
  +        else:
  +            upload_w = tex.update_rect.w
  +            upload_h = tex.update_rect.h

Activity

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions