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

Validation Error on Default Scene Render #291

Closed
power-unsealed opened this issue Mar 7, 2023 · 2 comments · Fixed by #630
Closed

Validation Error on Default Scene Render #291

power-unsealed opened this issue Mar 7, 2023 · 2 comments · Fixed by #630
Labels
bug Something isn't working

Comments

@power-unsealed
Copy link
Contributor

The following example tries to render an empty scene.

use vello::{util::RenderContext, Renderer, RendererOptions, Scene, RenderParams, peniko::Color};
use wgpu::{TextureDescriptor, Extent3d, TextureDimension, TextureFormat, TextureUsages, TextureViewDescriptor};
use pollster::FutureExt as _;

fn main() {
    let mut context = RenderContext::new().unwrap();
    let device_id = context.device(None).block_on().unwrap();
    let device_handle = &mut context.devices[device_id];
    let device = &device_handle.device;
    let queue = &device_handle.queue;
    let mut renderer = Renderer::new(
        device,
        &RendererOptions { surface_format: None }
    ).unwrap();

    let scene = Scene::default();
    let (width, height) = (1024, 1024);
    let texture = device.create_texture(&TextureDescriptor {
        label: Some("target"),
        size: Extent3d { width, height, depth_or_array_layers: 1 },
        mip_level_count: 1,
        sample_count: 1,
        dimension: TextureDimension::D2,
        format: TextureFormat::Rgba8Unorm,
        usage: TextureUsages::STORAGE_BINDING | TextureUsages::COPY_SRC,
        view_formats: &[],
    });
    let texture_view = texture.create_view(&TextureViewDescriptor::default());
    let params = RenderParams { base_color: Color::BLACK, width, height };

    renderer.render_to_texture(device, queue, &scene, &texture_view, &params).unwrap();
}

The code crashes at runtime with the following output:

thread 'main' panicked at 'wgpu error: Validation Error

Caused by:
    In a ComputePass
      note: encoder = `<CommandBuffer-(0, 1, Vulkan)>`
    In a dispatch command, indirect:false
      note: compute pipeline = `pathtag_reduce`
    Buffer is bound with size 16 where the shader expects 20 in group[0] compact index 2

The same happens, when rendering an empty scene to a winit window.

@DJMcNab
Copy link
Member

DJMcNab commented Mar 7, 2023

Thanks for the report.
This is because of https://www.w3.org/TR/webgpu/#minimum-buffer-binding-size

I think the correct fix might be to skip the parts of the render which fail if there are no paths, which may well be everything before fine. In theory, this case should be equivalent with clearing the given texture to the specified background colour? Can we make that "optimisation" to avoid needing to think about this.

For now, in user code, a workaround would be to always render something, e.g. a triangle of the background colour.

@power-unsealed
Copy link
Contributor Author

Clearing the target to a default color was actually something, that I was hoping for, when first stumbling across this bug. That would seem like a reasonable solution to me. 👍

@nicoburns nicoburns added the bug Something isn't working label Apr 12, 2023
github-merge-queue bot pushed a commit that referenced this issue Apr 22, 2024
…518)

* WIP: resurrect pico_svg and use it to load scenes.

* Add viewbox and width/height support to pico_svg.

* Accept more single-function transforms in pico_svg.

* Add copyright header to pico_svg.rs

* Remove vello_svg.

* Clean up pico_svg lints.

* Parse multiple transforms in attribute.

* Add scaleX and scaleY to pico_svg.

* Render fuchsia unit square on error, to work around #291.

* Print Display rather than Debug for Err in svg.rs

* Interpret combined viewBox and width/height correctly.

* Fix lint.

* Clean up std::result qualified names.

* Mention new vello_svg repository in ## Integrations

* Improve color parsing in pico_svg.

* Address review comments.
github-merge-queue bot pushed a commit that referenced this issue Jul 16, 2024
DJMcNab added a commit to DJMcNab/vello that referenced this issue Jul 16, 2024
DJMcNab added a commit that referenced this issue Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants