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

Discarding Acquired Surface Texture Does Not Work #2038

Open
Dispersia opened this issue Oct 8, 2021 · 4 comments
Open

Discarding Acquired Surface Texture Does Not Work #2038

Dispersia opened this issue Oct 8, 2021 · 4 comments
Labels
api: dx12 Issues with DX12 or DXGI api: gles Issues with GLES or WebGL api: metal Issues with Metal api: vulkan Issues with Vulkan area: correctness We're behaving incorrectly type: bug Something isn't working

Comments

@Dispersia
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Not calling present on current frame causes timeout error on next get_current_texture

Describe the solution you'd like
If it's possible, could it specify that the previous was not "closed" (not sure if that's the right terminology), instead of a generic timeout error? It took a while to find what I was missing on upgrade

Describe alternatives you've considered
Only other thing would be the close the last texture, but that doesn't feel super obvious what is wrong either as just nothing would be presented.

If the above makes sense (and is currently possible), I don't mind taking a whack at it

@kvark
Copy link
Member

kvark commented Oct 8, 2021

Are you dropping the frame, or keeping it around? If you are dropping it, then ideally we'd just not present this, so it would be a genuine behavioural bug on our side. In any way, I agree that the error message should be improved.

@kvark kvark added the type: bug Something isn't working label Oct 8, 2021
@Dispersia
Copy link
Contributor Author

The frame and view should be getting dropped, minimal example against 0.11:

use winit::{
    event::Event,
    event_loop::{ControlFlow, EventLoop},
    window::WindowBuilder,
};

#[tokio::main]
async fn main() {
    let event_loop = EventLoop::new();
    let window = WindowBuilder::new()
        .with_title("Test")
        .build(&event_loop)
        .expect("Could not create window");

    let instance = wgpu::Instance::new(wgpu::Backends::all());
    let surface = unsafe { instance.create_surface(&window) };

    let adapter = instance
        .request_adapter(&wgpu::RequestAdapterOptions {
            power_preference: wgpu::PowerPreference::HighPerformance,
            force_fallback_adapter: false,
            compatible_surface: Some(&surface),
        })
        .await
        .expect("No suitable GPU adapter found");

    let (device, _) = adapter
        .request_device(
            &wgpu::DeviceDescriptor {
                label: Some("slime::device"),
                features: wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES,
                limits: wgpu::Limits::default(),
            },
            None,
        )
        .await
        .expect("Unable to get gpu device");

    let format = surface.get_preferred_format(&adapter).unwrap();

    let surface_configuration = wgpu::SurfaceConfiguration {
        usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
        format,
        width: window.inner_size().width,
        height: window.inner_size().height,
        present_mode: wgpu::PresentMode::Mailbox,
    };

    surface.configure(&device, &surface_configuration);

    event_loop.run(move |event, _, control_flow| {
        *control_flow = ControlFlow::Poll;

        match event {
            Event::RedrawRequested(_) => {
                let frame = surface.get_current_texture().expect("Fail");
                let view = frame
                    .texture
                    .create_view(&wgpu::TextureViewDescriptor::default());
            }
            Event::MainEventsCleared => {
                window.request_redraw();
            }
            _ => {}
        }
    })
}

@kvark
Copy link
Member

kvark commented Oct 11, 2021

Thanks! So looks like our logic of discarding a frame doesn't work as expected.

@HalfVoxel
Copy link
Contributor

I also ran into this when upgrading wgpu. Took a while to figure out that it was now necessary to call present.

Patryk27 pushed a commit to Patryk27/wgpu that referenced this issue Nov 23, 2022
The Vulkan decoration rules require us to distinguish vertex shader
inputs, fragment shader inputs, and everything else, so just pass the
stage to `Writer::write_varying`. Together with the SPIRV storage
class, this is sufficient to distinguish all the cases in a way that
closely follows the spec language.
@cwfitzgerald cwfitzgerald changed the title Timeout on surface.get_current_texture when frame.present not called Discarding Acquired Surface Texture Does Not Work Dec 11, 2024
@cwfitzgerald cwfitzgerald added area: correctness We're behaving incorrectly api: dx12 Issues with DX12 or DXGI api: metal Issues with Metal api: gles Issues with GLES or WebGL api: vulkan Issues with Vulkan labels Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: dx12 Issues with DX12 or DXGI api: gles Issues with GLES or WebGL api: metal Issues with Metal api: vulkan Issues with Vulkan area: correctness We're behaving incorrectly type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants