gfx-rs / gfx

[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
http://gfx-rs.github.io/
Apache License 2.0
5.35k stars 549 forks source link

[GL] Panic with missing fragment shader #3580

Closed Gordon-F closed 3 years ago

Gordon-F commented 3 years ago

Short info header:

Use case: wgpu-rs shadow example.

2021-01-12 01:58:20.891 32464-32491/rust.example.shadow D/gfx_backend_gl::device: SPIR-V options CompilerOptions { version: V3_00Es, force_temporary: false, vulkan_semantics: false, separate_shader_objects: false, flatten_multidimensional_arrays: false, enable_420_pack_extension: true, emit_push_constant_as_uniform_buffer: false, emit_uniform_buffer_as_plain_uniforms: false, emit_line_directives: false, enable_storage_image_qualifier_deduction: true, force_zero_initialized_variables: true, vertex: CompilerVertexOptions { invert_y: false, transform_clip_space: false, support_nonzero_base_instance: true }, fragment: CompilerFragmentOptions { default_float_precision: Medium, default_int_precision: High }, entry_point: Some(("main", Vertex)) }
2021-01-12 01:58:20.894 32464-32491/rust.example.shadow D/gfx_backend_gl::device: SPIRV-Cross generated shader:
    #version 300 es

    layout(std140) uniform Globals
    {
        mat4 u_ViewProj;
    } _19;

    layout(std140) uniform Entity
    {
        mat4 u_World;
        vec4 u_Color;
    } _25;

    layout(location = 0) in ivec4 a_Pos;

    void main()
    {
        gl_Position = (_19.u_ViewProj * _25.u_World) * vec4(a_Pos);
    }
2021-01-12 01:58:20.896 825-5882/? D/WindowManager: finishDrawingWindow: Window{b36b88 u0 StatusBar} mDrawState=READY_TO_SHOW
2021-01-12 01:58:20.898 32464-32491/rust.example.shadow I/gfx_backend_gl::device:   Compiled shader 2
2021-01-12 01:58:20.898 32464-32491/rust.example.shadow I/gfx_backend_gl::device:   Linked program 1
2021-01-12 01:58:20.898 32464-32491/rust.example.shadow E/gfx_backend_gl::device:   Log: Link failed because of missing fragment shader.
2021-01-12 01:58:20.899 32464-32490/rust.example.shadow I/RustStdoutStderr: thread '<unnamed>' panicked at 'failed to create graphics pipeline: Implementation specific error occurred', /Users/indish/Dev/RustProjects/wgpu/wgpu-core/src/device/mod.rs:2207:26

Any ideas how we can fix it? Can we just add empty fragment shader when only vertex shader present?

#version 300 es
void main(void) {}
kvark commented 3 years ago

Given that this runs on Vulkan, I suppose it's the GL backend that needs to add an empty fragment shader if the pipeline doesn't offer one. Should be an easy fix. Are you interested in trying to get this running?