Skip to content
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

Modal Popup scissor rect larger than render target extent #731

Open
junglie85 opened this issue Jun 19, 2023 · 0 comments
Open

Modal Popup scissor rect larger than render target extent #731

junglie85 opened this issue Jun 19, 2023 · 0 comments

Comments

@junglie85
Copy link

Rendering a modal popup panics because the scissor rect is larger than the render target extent.

This code causes the panic:

let style = ui.push_style_var(StyleVar::FramePadding([0.0, 0.0]));
if close_requested && !self.state.close_requested {
    self.state.close_requested = true;
    ui.open_popup("Quit?");
}

if self.state.close_requested {
    ui.modal_popup_config("Quit?")
        .always_auto_resize(true)
        .build(|| {
            ui.text("Are you sure you want to quit?");
            ui.separator();

            ui.checkbox("Don't ask again", &mut self.state.confirm_quit); // todo: save this in editor config

            if ui.button_with_size("Ok", [120.0, 0.0]) {
                self.state.quit = true;
                ui.close_current_popup();
            }
            ui.same_line();
            if ui.button_with_size("Cancel", [120.0, 0.0]) {
                self.state.quit = false;
                ui.close_current_popup();
            }
        });
}
style.pop();
thread 'main' panicked at 'wgpu error: Validation Error

Caused by:
    In a RenderPass
      note: encoder = `encoder`
    In a set_scissor_rect command
    Scissor Rect { x: 0, y: 0, w: 1282, h: 722 } is not contained in the render target Extent3d { width: 1280, height: 720, depth_or_array_layers: 1 }

', C:\Users\junglie85\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-0.16.1\src\backend\direct.rs:3019:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I'm not sure if this is a bug (either imgui-rs or imgui-wgpu-rs) or whether I'm using the API incorrectly. Stepping through the DrawList, it looks to me like the data is incorrect:

image

Is this imgui-rs producing incorrect clip values or should imgui-wgpu be handling this differently?

let clip_rect = [
    (cmd_params.clip_rect[0] - clip_off[0]) * clip_scale[0],
    (cmd_params.clip_rect[1] - clip_off[1]) * clip_scale[1],
    (cmd_params.clip_rect[2] - clip_off[0]) * clip_scale[0],
    (cmd_params.clip_rect[3] - clip_off[1]) * clip_scale[1],
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant