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

OpenGL surface via surfman #3151

Merged
merged 5 commits into from
Apr 14, 2020
Merged

OpenGL surface via surfman #3151

merged 5 commits into from
Apr 14, 2020

Conversation

zicklag
Copy link
Contributor

@zicklag zicklag commented Feb 25, 2020

Fixes/Discussion: gfx-rs/wgpu#450

PR checklist:

  • make succeeds (on *nix)
  • make reftests succeeds
  • tested examples with the following backends:
    • GL ( excluding compute because it isn't supported )
  • rustfmt run on changed code

Adds a surfman backend to gfx-backend-gl and makes it the default
backend for unix platforms.
src/backend/gl/src/lib.rs Outdated Show resolved Hide resolved
@zicklag zicklag changed the base branch from master to hal-0.4 February 26, 2020 02:33
@zicklag
Copy link
Contributor Author

zicklag commented Feb 29, 2020

If surfman works do you think we remove the glutin feature and make it the only option? If surfman is the only way to support the desired API, we probably want to.

I'm asking because I think I might take out the glutin code just to help me think while understanding the code and avoid a bunch of feature gates, even if I add it in again afterwards.

@zicklag
Copy link
Contributor Author

zicklag commented Mar 1, 2020

Another question: for the Headless instance type, should create_surface completely ignore the window handle and create a headless surface? That's what I'm assuming the intent is, but I couldn't be sure because it still receives a raw window handle. Is that just to be compatible with the non-headless API?

@kvark
Copy link
Member

kvark commented Mar 1, 2020

@zicklag I haven't investigated surfman in depth. My understanding was that it doesn't work on Windows in the way we want (no resource sharing). Also, if the glutin path can work in the way we want (with pure context for the instance), it would still be nice to keep supporting it. So all in all, I would prefer the glutin path to stay, even if it's only partially usable today.

for the Headless instance type

I don't think there should be a headless instance type. Ideally, we'd expose it at the physical device level. One physical device would be "software", while another will be "hardware". When the user creates a surface, they don't know about a physical device, but the API clearly has means to express that different physical devices can work with different surfaces via supports_queue_family (each physical device would only expose one queue family, and you can make it so the headless physical device is only compatible with headless surfaces. I.e. the only point of divergence on the API level would be the way a surface is created: we could have create_emulated_surface versus another create_surface for accelerated surfaces.

@zicklag
Copy link
Contributor Author

zicklag commented Mar 1, 2020

So all in all, I would prefer the glutin path to stay, even if it's only partially usable today.

Sounds good.

Ideally, we'd expose it at the physical device level. One physical device would be "software", while another will be "hardware".

I think I get it. I'll see about that then. I'll try to get non-headless to work first.


Also, what is wgl? Is that for windows?

@kvark
Copy link
Member

kvark commented Mar 1, 2020 via email

@zicklag
Copy link
Contributor Author

zicklag commented Mar 1, 2020

So ideally would we want to support glutin and wgl in separate feature flags, or just rely on glutin to do it?

@kvark
Copy link
Member

kvark commented Mar 1, 2020

Overall, Windows is least of a priority for GL (so just because surfman has problems with it doesn't mean we can't technically leave it as the only choice): since on Windows we also have D3D11, D3D12, and Vulkan. I would be totally fine if our GL backend was simply not available on Windows, or expose only compute abilities, or had only software implementation.

For your work, try to focus on Linux & Android first and foremost, then macOS/iOS, and only afterwards - Windows. No need to consider a separate WGL code path at this point :)

src/backend/gl/src/lib.rs Outdated Show resolved Hide resolved
@zicklag
Copy link
Contributor Author

zicklag commented Mar 2, 2020

I think I have the surfman backend mostly in the state that I want it and it compiles, but I haven't yet gotten it to finish linking so I haven't been able to run it yet. I'm assuming that the problem has to do with my build environment, but I'll have to look more into it.

I managed to leave the glutin and wgl backends in the code for now as I got a better grip on the code organization.


Requires a surfman PR: pcwalton/surfman#61.

@kvark
Copy link
Member

kvark commented Mar 2, 2020

Perhaps, we need to call set_instance somewhere? :)

@zicklag
Copy link
Contributor Author

zicklag commented Mar 2, 2020

Oops, I had that in there earlier! I lost it in a refactor. :)

@zicklag
Copy link
Contributor Author

zicklag commented Mar 2, 2020

Do you have any idea what's wrong if I'm getting undefined symbols while linking X11:

 = note: ld: error: undefined symbol: XOpenDisplay
          >>> referenced by connection.rs:79 (/home/zicklag/git/other/surfman/surfman/src/platform/unix/x11/connection.rs:79)
          >>>               gfx_backend_gl-d96c34389fc1283e.29fwo7artum5a8yx.rcgu.o:(surfman::platform::unix::x11::connection::Connection::new::h891448e5eadb68ed) in archive /home/zicklag/git/other/wgpu-rs/target/debug/deps/libgfx_backend_gl-d96c34389fc1283e.rlib
....

And more like that.

I've got a weird setup right now because I'm not an admin on the system I'm using to build, but it doesn't have libx11-dev installed, so to remedy that I downloaded the libx11-dev package source and copied the headers into ~/.local/include/x11 and wrote a x11.pc that includes it.

Apparently I did something wrong, but what does the undefined symbol mean? Does that mean I'm not linking X11 in? Like I'm missing a -l flag to the linker?

@kvark
Copy link
Member

kvark commented Mar 2, 2020

Yes definitely missing a link to x11 library.

@zicklag
Copy link
Contributor Author

zicklag commented Mar 2, 2020

Ah, thanks. Got it to by adding -lX11 -L$HOME/.local/lib to RUSTFLAGS and symlinking my /usr/lib/libX11.so.6 to $HOME/.local/libX11.so. I keep forgetting that -lsomelib won't look at libsomelib.so.suffix. And I think that this system doesn't symlink the libs with suffixes by default like my old one did. Or maybe that is a part of the -dev packages? Anyway, doesn't matter too much.

I don't know why it didn't "Just Work". Maybe surfman doesn't use pkg-config or something.

Now I've got a panic in surfman to track down, but it's better than a linker error. 😉

@zicklag
Copy link
Contributor Author

zicklag commented Mar 2, 2020

Hey, we're getting close. You have any idea what this means?

[2020-03-02T03:56:52Z ERROR gfx_backend_gl] [API/Error] ID 1 : GL_INVALID_FRAMEBUFFER_OPERATION in glBlitFramebuffer(incomplete draw/read buffers)
[2020-03-02T03:56:52Z TRACE wgpu_core::command::allocator] recycling comb submitted in 3 when 4 is lowest active
[2020-03-02T03:56:52Z TRACE wgpu_core::command::render] Encoding render pass begin in command buffer (0, 4, Gl)
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl::device] create_framebuffer [Renderbuffer(1)]
thread 'main' panicked at 'Error creating FBO: InvalidFramebufferOperation for RenderPass { attachments: [Attachment { format: Some(Bgra8Srgb), samples: 1, ops: AttachmentOps { load: Clear, store: Store }, stencil_ops: AttachmentOps { load: DontCare, store: DontCare }, layouts: Undefined..Present }], subpasses: [SubpassDesc { color_attachments: [0], depth_stencil: None }] }'

The panic is from here.

And the entire trace log:

[2020-03-02T03:56:52Z TRACE mio::poll] registering with poller
[2020-03-02T03:56:52Z TRACE mio::poll] registering with poller
[2020-03-02T03:56:52Z TRACE mio::poll] registering with poller
[2020-03-02T03:56:52Z INFO  cube::framework] Initializing the window...
[2020-03-02T03:56:52Z INFO  winit::platform_impl::platform::x11::window] Guessed window scale factor: 1
[2020-03-02T03:56:52Z DEBUG winit::platform_impl::platform::x11::window] Calculated physical dimensions: 800x600
[2020-03-02T03:56:52Z WARN  gfx_backend_vulkan] Unable to find layer: VK_LAYER_LUNARG_standard_validation
libEGL warning: DRI2: failed to authenticate
[2020-03-02T03:56:52Z ERROR gfx_backend_vulkan] 
    GENERAL [Loader Message (0)] : setupLoaderTermPhysDevs:  Failed to detect any valid GPUs in the current config
    object info: (type: INSTANCE, hndl: 94804708591264)
    
[2020-03-02T03:56:52Z ERROR gfx_backend_vulkan] 
    GENERAL [Loader Message (0)] : setupLoaderTrampPhysDevs:  Failed during dispatch call of 'vkEnumeratePhysicalDevices' to lower layers or loader to get count.
    object info: (type: INSTANCE, hndl: 94804708591264)
    
[2020-03-02T03:56:52Z ERROR gfx_backend_vulkan] 
    GENERAL [Loader Message (0)] : setupLoaderTermPhysDevs:  Failed to detect any valid GPUs in the current config
    object info: (type: INSTANCE, hndl: 94804708591264)
    
[2020-03-02T03:56:52Z ERROR gfx_backend_vulkan] 
    GENERAL [Loader Message (0)] : setupLoaderTrampPhysDevs:  Failed during dispatch call of 'vkEnumeratePhysicalDevices' to lower layers or loader to get count.
    object info: (type: INSTANCE, hndl: 94804708591264)
    
[2020-03-02T03:56:52Z ERROR gfx_backend_vulkan] Could not enumerate physical devices! Initialization of a object has failed
[/home/zicklag/git/other/wgpu/wgpu-core/src/instance.rs:388] &instance = Instance {
    vulkan: Some(
        Instance,
    ),
    gl: Some(
        Instance {
            device: 0x563971117390@ThreadId(1),
            connection: 0x563971119ee0@ThreadId(1),
            context: 0x563971283560@ThreadId(1),
        },
    ),
}
[/home/zicklag/git/other/wgpu/wgpu-core/src/instance.rs:391] &inst = Instance {
    device: 0x563971117390@ThreadId(1),
    connection: 0x563971119ee0@ThreadId(1),
    context: 0x563971283560@ThreadId(1),
}
[2020-03-02T03:56:52Z INFO  gfx_backend_gl] Vendor: "VMware, Inc."
[2020-03-02T03:56:52Z INFO  gfx_backend_gl] Renderer: "llvmpipe (LLVM 8.0, 256 bits)"
[2020-03-02T03:56:52Z INFO  gfx_backend_gl] Version: 3.3, (Core Profile) Mesa 19.0.8
[2020-03-02T03:56:52Z INFO  gfx_backend_gl] Shading Language: 3.30
[2020-03-02T03:56:52Z INFO  gfx_backend_gl] Features: INDEPENDENT_BLENDING | INSTANCE_RATE | SAMPLER_MIP_LOD_BIAS
[2020-03-02T03:56:52Z INFO  gfx_backend_gl] Legacy Features: DRAW_INSTANCED | DRAW_INSTANCED_BASE | DRAW_INDEXED_BASE | DRAW_INDEXED_INSTANCED | DRAW_INDEXED_INSTANCED_BASE_VERTEX | VERTEX_BASE | SRGB_COLOR | CONSTANT_BUFFER | COPY_BUFFER | SAMPLER_OBJECTS | SAMPLER_BORDER_COLOR | INSTANCED_ATTRIBUTE_BINDING
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] Loaded Extensions:
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_separate_shader_objects
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_framebuffer_object
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_draw_buffers_blend
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_texture_compression_rgtc
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_KHR_context_flush_control
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_MESA_pack_invert
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_internalformat_query
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_draw_buffers
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_texture_swizzle
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_MESA_ycbcr_texture
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_gpu_shader_int64
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_vertex_type_10f_11f_11f_rev
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_transform_feedback
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_enhanced_layouts
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_AMD_shader_trinary_minmax
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_copy_image
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_point_sprite
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_shader_subroutine
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_transform_feedback2
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_vertex_array_bgra
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_vertex_shader
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_provoking_vertex
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_texture_compression_dxt1
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_timer_query
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_framebuffer_sRGB
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_IBM_multimode_draw_arrays
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_texture_compression_s3tc
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_KHR_debug
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_rg
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_vertex_attrib_64bit
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_NV_packed_depth_stencil
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_MESA_texture_signed_rgba
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_buffer_storage
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_KHR_texture_compression_astc_ldr
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_buffer_object_rgb32
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_arrays_of_arrays
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_get_program_binary
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_query_lod
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_query_levels
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_blend_func_extended
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_multi_draw_indirect
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_pixel_buffer_object
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_ES2_compatibility
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_map_buffer_alignment
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_texture_array
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ATI_blend_equation_separate
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_framebuffer_multisample
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_texture_shared_exponent
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_vertex_array_bgra
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_MESA_shader_integer_functions
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_explicit_attrib_location
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_gpu_shader_fp64
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_framebuffer_sRGB
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_stencil8
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_storage
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_packed_float
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_texture_sRGB_decode
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_sync
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_explicit_uniform_location
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_vertex_attrib_binding
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_pixel_buffer_object
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_AMD_shader_stencil_export
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ANGLE_texture_compression_dxt3
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_half_float_pixel
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_storage_multisample
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_transform_feedback_instanced
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_transform_feedback_overflow_query
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_draw_buffers2
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_clip_control
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_shader_bit_encoding
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_rectangle
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_viewport_array
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_cube_map_array
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_AMD_vertex_shader_viewport_index
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_packed_depth_stencil
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_polygon_offset_clamp
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_shading_language_packing
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_vertex_array_object
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ATI_texture_mirror_once
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_clear_buffer_object
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_depth_buffer_float
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_shader_stencil_export
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_half_float_vertex
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_AMD_conservative_depth
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_draw_instanced
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_direct_state_access
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_framebuffer_multisample_blit_scaled
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_instanced_arrays
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_compressed_texture_pixel_storage
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_occlusion_query2
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_fragment_coord_conventions
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_copy_buffer
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_map_buffer_range
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_stencil_texturing
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_multisample
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_vertex_buffer_object
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_depth_clamp
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_AMD_gpu_shader_int64
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_texture_sRGB
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_invalidate_subdata
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_buffer_object
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_AMD_texture_texture4
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_robustness
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_get_texture_sub_image
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_debug_output
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_cull_distance
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_sampler_objects
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_non_power_of_two
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_seamless_cube_map
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_shader_objects
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_mirror_clamp_to_edge
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_ES3_compatibility
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_timer_query
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_NV_conditional_render
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_NV_depth_clamp
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_fragment_shader
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_compression_bptc
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_float
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_blend_equation_separate
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_gather
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_framebuffer_blit
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_draw_instanced
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_shader_integer_mix
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_texture_integer
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_internalformat_query2
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_view
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_KHR_no_error
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_shader_texture_lod
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_multi_bind
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_pipeline_statistics_query
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_compression_rgtc
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_framebuffer_object
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_texture_mirror_clamp
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_polygon_offset_clamp
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_draw_indirect
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_fragment_layer_viewport
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_AMD_vertex_shader_layer
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_S3_s3tc
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_buffer_range
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_OES_EGL_image
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_draw_elements_base_vertex
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_seamless_cubemap_per_texture
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_AMD_multi_draw_indirect
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_conservative_depth
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_provoking_vertex
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_shading_language_420pack
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ANGLE_texture_compression_dxt5
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_AMD_seamless_cubemap_per_texture
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_conditional_render_inverted
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_swizzle
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_transform_feedback3
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_program_interface_query
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_AMD_draw_buffers_blend
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_uniform_buffer_object
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ATI_texture_float
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_texture_rgb10_a2ui
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_texture_snorm
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_vertex_attrib_64bit
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_EXT_abgr
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_clear_texture
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_KHR_texture_compression_astc_sliced_3d
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_vertex_type_2_10_10_10_rev
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl] - GL_ARB_base_instance
[2020-03-02T03:56:52Z INFO  gfx_backend_gl] Memory types: [
        (
            MemoryType {
                properties: CPU_VISIBLE | COHERENT | CPU_CACHED,
                heap_index: 1,
            },
            Buffer(
                TRANSFER_SRC | TRANSFER_DST | UNIFORM_TEXEL | STORAGE_TEXEL | UNIFORM | STORAGE | INDEX | VERTEX | INDIRECT,
            ),
        ),
        (
            MemoryType {
                properties: CPU_VISIBLE | COHERENT,
                heap_index: 1,
            },
            Buffer(
                TRANSFER_SRC | TRANSFER_DST | UNIFORM_TEXEL | STORAGE_TEXEL | UNIFORM | STORAGE | INDEX | VERTEX | INDIRECT,
            ),
        ),
        (
            MemoryType {
                properties: CPU_VISIBLE | CPU_CACHED,
                heap_index: 1,
            },
            Buffer(
                TRANSFER_SRC | TRANSFER_DST | UNIFORM_TEXEL | STORAGE_TEXEL | UNIFORM | STORAGE | INDEX | VERTEX | INDIRECT,
            ),
        ),
        (
            MemoryType {
                properties: DEVICE_LOCAL,
                heap_index: 0,
            },
            Buffer(
                TRANSFER_SRC | TRANSFER_DST | UNIFORM_TEXEL | STORAGE_TEXEL | UNIFORM | STORAGE | INDEX | VERTEX | INDIRECT,
            ),
        ),
        (
            MemoryType {
                properties: DEVICE_LOCAL,
                heap_index: 0,
            },
            Image,
        ),
    ]
[2020-03-02T03:56:52Z DEBUG wgpu_core::instance] Power info unavailable, preferring integrated gpu (Battery status is unsupported on this platform)
[2020-03-02T03:56:52Z INFO  wgpu_core::instance] Adapter GL AdapterInfo { name: "llvmpipe (LLVM 8.0, 256 bits)", vendor: 0, device: 0, device_type: DiscreteGpu }
[2020-03-02T03:56:52Z WARN  wgpu_core::instance] max_bind_groups limit is missing
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::linear] Create new 'linear' allocator: type: 'MemoryTypeId(0)', properties: 'CPU_VISIBLE | COHERENT | CPU_CACHED' config: 'LinearConfig {
        linear_size: 1048576,
    }'
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Create new allocator: type: 'MemoryTypeId(0)', properties: 'CPU_VISIBLE | COHERENT | CPU_CACHED' config: 'DynamicConfig {
        block_size_granularity: 256,
        max_chunk_size: 16777216,
        min_device_allocation: 65536,
    }'
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::linear] Create new 'linear' allocator: type: 'MemoryTypeId(1)', properties: 'CPU_VISIBLE | COHERENT' config: 'LinearConfig {
        linear_size: 1048576,
    }'
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Create new allocator: type: 'MemoryTypeId(1)', properties: 'CPU_VISIBLE | COHERENT' config: 'DynamicConfig {
        block_size_granularity: 256,
        max_chunk_size: 16777216,
        min_device_allocation: 65536,
    }'
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::linear] Create new 'linear' allocator: type: 'MemoryTypeId(2)', properties: 'CPU_VISIBLE | CPU_CACHED' config: 'LinearConfig {
        linear_size: 1048576,
    }'
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Create new allocator: type: 'MemoryTypeId(2)', properties: 'CPU_VISIBLE | CPU_CACHED' config: 'DynamicConfig {
        block_size_granularity: 256,
        max_chunk_size: 16777216,
        min_device_allocation: 65536,
    }'
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Create new allocator: type: 'MemoryTypeId(3)', properties: 'DEVICE_LOCAL' config: 'DynamicConfig {
        block_size_granularity: 256,
        max_chunk_size: 16777216,
        min_device_allocation: 65536,
    }'
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Create new allocator: type: 'MemoryTypeId(4)', properties: 'DEVICE_LOCAL' config: 'DynamicConfig {
        block_size_granularity: 256,
        max_chunk_size: 16777216,
        min_device_allocation: 65536,
    }'
[2020-03-02T03:56:52Z INFO  wgpu_core::device] creating swap chain SwapChainDescriptor { usage: OUTPUT_ATTACHMENT, format: Bgra8UnormSrgb, width: 800, height: 600, present_mode: Vsync }
[2020-03-02T03:56:52Z INFO  cube::framework] Initializing the example...
[2020-03-02T03:56:52Z INFO  gfx_backend_gl::device]     Created frame buffer 2
[2020-03-02T03:56:52Z TRACE rendy_memory::heaps] Allocate memory block: type '1', usage 'Dynamic', size: '576', align: '4'
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate dynamic block: size: 576, align: 4, aligned size: 768, type: 1
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate block of size 768
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks for size 768 from the entry
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate chunk for blocks of size 768 (1 total blocks allocated)
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate block of size 4096
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks for size 4096 from the entry
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate chunk for blocks of size 4096 (1 total blocks allocated)
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate block of size 32768
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks for size 32768 from the entry
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate chunk for blocks of size 32768 (1 total blocks allocated)
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate block of size 262144
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks for size 262144 from the entry
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate chunk for blocks of size 262144 (1 total blocks allocated)
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate chunk of size: 262144 for blocks of size 262144 from device
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Map new memory object
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks of size 262144 from chunk 0
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks of size 32768 from chunk 0
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks of size 4096 from chunk 0
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks of size 768 from chunk 0
[2020-03-02T03:56:52Z TRACE rendy_memory::heaps] Allocate memory block: type '1', usage 'Dynamic', size: '72', align: '4'
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate dynamic block: size: 72, align: 4, aligned size: 256, type: 1
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate block of size 256
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks for size 256 from the entry
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate chunk for blocks of size 256 (1 total blocks allocated)
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate block of size 2048
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks for size 2048 from the entry
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate chunk for blocks of size 2048 (1 total blocks allocated)
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate block of size 16384
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks for size 16384 from the entry
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate chunk for blocks of size 16384 (1 total blocks allocated)
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate block of size 131072
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks for size 131072 from the entry
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate chunk for blocks of size 131072 (1 total blocks allocated)
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate chunk of size: 131072 for blocks of size 131072 from device
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Map new memory object
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks of size 131072 from chunk 0
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks of size 16384 from chunk 0
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks of size 2048 from chunk 0
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks of size 256 from chunk 0
[2020-03-02T03:56:52Z TRACE rendy_memory::heaps] Allocate memory block: type '4', usage 'Data', size: '262144', align: '1'
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate dynamic block: size: 262144, align: 1, aligned size: 262144, type: 4
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate block of size 262144
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks for size 262144 from the entry
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate chunk for blocks of size 262144 (1 total blocks allocated)
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate chunk of size: 262144 for blocks of size 262144 from device
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks of size 262144 from chunk 0
[2020-03-02T03:56:52Z TRACE rendy_memory::heaps] Allocate memory block: type '1', usage 'Upload', size: '262144', align: '4'
[2020-03-02T03:56:52Z TRACE rendy_memory::heaps] Allocate memory block: type '1', usage 'Dynamic', size: '64', align: '4'
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate dynamic block: size: 64, align: 4, aligned size: 256, type: 1
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate block of size 256
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks for size 256 from the entry
[2020-03-02T03:56:52Z TRACE rendy_memory::allocator::dynamic] Allocate 1 consecutive blocks of size 256 from chunk 0
[2020-03-02T03:56:52Z TRACE rendy_descriptor::allocator] Allocating 1 sets with layout [DescriptorSetLayoutBinding { binding: 0, ty: UniformBuffer, count: 1, stage_flags: VERTEX, immutable_samplers: false }, DescriptorSetLayoutBinding { binding: 1, ty: SampledImage, count: 1, stage_flags: FRAGMENT, immutable_samplers: false }, DescriptorSetLayoutBinding { binding: 2, ty: Sampler, count: 1, stage_flags: FRAGMENT, immutable_samplers: false }] @ DescriptorRanges { counts: [1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0] }
[2020-03-02T03:56:52Z TRACE rendy_descriptor::allocator] Create new pool with 64 sets and DescriptorRanges { counts: [64, 0, 64, 0, 0, 0, 64, 0, 0, 0, 0] } descriptors
[2020-03-02T03:56:52Z DEBUG wgpu_core::device] Bind group (0, 1, Gl) TrackerSet {
        buffers: {
            (
                3,
                1,
            ): Unit {
                first: None,
                last: UNIFORM,
            },
        },
        textures: {
            (
                0,
                1,
            ): TextureState {
                mips: [
                    RangedStates {
                        ranges: [
                            (
                                0..1,
                                Unit {
                                    first: None,
                                    last: SAMPLED,
                                },
                            ),
                        ],
                    },
                ],
                full: false,
            },
        },
        views: {
            (
                0,
                1,
            ): PhantomData,
        },
        bind_groups: {},
        samplers: {
            (
                0,
                1,
            ): PhantomData,
        },
    }
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl::device] SPIR-V options CompilerOptions { version: V3_30, vertex: CompilerVertexOptions { invert_y: true, transform_clip_space: false } }
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl::device] SPIRV-Cross generated shader:
    #version 330
    #ifdef GL_ARB_shading_language_420pack
    #extension GL_ARB_shading_language_420pack : require
    #endif
    
    layout(std140) uniform Locals
    {
        mat4 u_Transform;
    } _25;
    
    out vec2 v_TexCoord;
    layout(location = 1) in vec2 a_TexCoord;
    layout(location = 0) in vec4 a_Pos;
    
    void main()
    {
        v_TexCoord = a_TexCoord;
        gl_Position = _25.u_Transform * a_Pos;
        gl_Position.y = -gl_Position.y;
    }
    
    
[2020-03-02T03:56:52Z INFO  gfx_backend_gl::device]     Compiled shader 2
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl::device] SPIR-V options CompilerOptions { version: V3_30, vertex: CompilerVertexOptions { invert_y: true, transform_clip_space: false } }
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl::device] SPIRV-Cross generated shader:
    #version 330
    #ifdef GL_ARB_shading_language_420pack
    #extension GL_ARB_shading_language_420pack : require
    #endif
    
    uniform sampler2D GFX_HAL_COMBINED_SAMPLER_16_12_43;
    
    in vec2 v_TexCoord;
    layout(location = 0) out vec4 o_Target;
    
    void main()
    {
        vec4 tex = texture(GFX_HAL_COMBINED_SAMPLER_16_12_43, v_TexCoord);
        float mag = length(v_TexCoord - vec2(0.5));
        o_Target = mix(tex, vec4(0.0), vec4(mag * mag));
    }
    
    
[2020-03-02T03:56:52Z INFO  gfx_backend_gl::device]     Compiled shader 3
[2020-03-02T03:56:52Z INFO  gfx_backend_gl::device]     Linked program 1
[2020-03-02T03:56:52Z DEBUG wgpu_core::command] Command buffer (0, 1, Gl) TrackerSet {
        buffers: {
            (
                2,
                1,
            ): Unit {
                first: Some(
                    NONE,
                ),
                last: COPY_SRC,
            },
        },
        textures: {
            (
                0,
                1,
            ): TextureState {
                mips: [
                    RangedStates {
                        ranges: [
                            (
                                0..1,
                                Unit {
                                    first: Some(
                                        COPY_DST,
                                    ),
                                    last: COPY_DST,
                                },
                            ),
                        ],
                    },
                ],
                full: false,
            },
        },
        views: {},
        bind_groups: {},
        samplers: {},
    }
[2020-03-02T03:56:52Z TRACE wgpu_core::device] Stitching command buffer (0, 1, Gl) before submission
[2020-03-02T03:56:52Z DEBUG wgpu_core::device] Device after submission 2: TrackerSet {
        buffers: {
            (
                2,
                1,
            ): Unit {
                first: Some(
                    MAP_WRITE,
                ),
                last: COPY_SRC,
            },
            (
                3,
                1,
            ): Unit {
                first: None,
                last: MAP_WRITE,
            },
            (
                0,
                1,
            ): Unit {
                first: None,
                last: MAP_WRITE,
            },
            (
                1,
                1,
            ): Unit {
                first: None,
                last: MAP_WRITE,
            },
        },
        textures: {
            (
                0,
                1,
            ): TextureState {
                mips: [
                    RangedStates {
                        ranges: [
                            (
                                0..1,
                                Unit {
                                    first: Some(
                                        COPY_SRC | COPY_DST | SAMPLED | STORAGE | OUTPUT_ATTACHMENT | READ_ALL | WRITE_ALL | ORDERED | UNINITIALIZED,
                                    ),
                                    last: COPY_DST,
                                },
                            ),
                        ],
                    },
                ],
                full: true,
            },
        },
        views: {
            (
                0,
                1,
            ): PhantomData,
        },
        bind_groups: {
            (
                0,
                1,
            ): PhantomData,
        },
        samplers: {
            (
                0,
                1,
            ): PhantomData,
        },
    }
[2020-03-02T03:56:52Z INFO  cube::framework] Entering render loop...
[2020-03-02T03:56:52Z INFO  cube::framework] Resizing to PhysicalSize { width: 800, height: 600 }
[2020-03-02T03:56:52Z INFO  wgpu_core::device] creating swap chain SwapChainDescriptor { usage: OUTPUT_ATTACHMENT, format: Bgra8UnormSrgb, width: 800, height: 600, present_mode: Vsync }
[2020-03-02T03:56:52Z TRACE rendy_memory::heaps] Allocate memory block: type '1', usage 'Upload', size: '64', align: '4'
[2020-03-02T03:56:52Z TRACE wgpu_core::track]   buffer -> PendingTransition { id: (4, 1, Gl), selector: (), usage: NONE..COPY_SRC }
[2020-03-02T03:56:52Z TRACE wgpu_core::track]   buffer -> PendingTransition { id: (3, 1, Gl), selector: (), usage: NONE..COPY_DST }
[2020-03-02T03:56:52Z DEBUG wgpu_core::command] Command buffer (0, 2, Gl) TrackerSet {
        buffers: {
            (
                4,
                1,
            ): Unit {
                first: Some(
                    NONE,
                ),
                last: COPY_SRC,
            },
            (
                3,
                1,
            ): Unit {
                first: Some(
                    NONE,
                ),
                last: COPY_DST,
            },
        },
        textures: {},
        views: {},
        bind_groups: {},
        samplers: {},
    }
[2020-03-02T03:56:52Z TRACE wgpu_core::device] Stitching command buffer (0, 2, Gl) before submission
[2020-03-02T03:56:52Z DEBUG wgpu_core::device] Device after submission 3: TrackerSet {
        buffers: {
            (
                2,
                1,
            ): Unit {
                first: Some(
                    MAP_WRITE,
                ),
                last: COPY_SRC,
            },
            (
                3,
                1,
            ): Unit {
                first: Some(
                    MAP_WRITE,
                ),
                last: COPY_DST,
            },
            (
                0,
                1,
            ): Unit {
                first: None,
                last: MAP_WRITE,
            },
            (
                4,
                1,
            ): Unit {
                first: Some(
                    MAP_WRITE,
                ),
                last: COPY_SRC,
            },
            (
                1,
                1,
            ): Unit {
                first: None,
                last: MAP_WRITE,
            },
        },
        textures: {
            (
                0,
                1,
            ): TextureState {
                mips: [
                    RangedStates {
                        ranges: [
                            (
                                0..1,
                                Unit {
                                    first: Some(
                                        COPY_SRC | COPY_DST | SAMPLED | STORAGE | OUTPUT_ATTACHMENT | READ_ALL | WRITE_ALL | ORDERED | UNINITIALIZED,
                                    ),
                                    last: COPY_DST,
                                },
                            ),
                        ],
                    },
                ],
                full: true,
            },
        },
        views: {
            (
                0,
                1,
            ): PhantomData,
        },
        bind_groups: {
            (
                0,
                1,
            ): PhantomData,
        },
        samplers: {
            (
                0,
                1,
            ): PhantomData,
        },
    }
[2020-03-02T03:56:52Z TRACE wgpu_core::device::life] Active submission 2 is done
[2020-03-02T03:56:52Z TRACE wgpu_core::command::allocator] recycling comb submitted in 2 when 3 is lowest active
[2020-03-02T03:56:52Z TRACE wgpu_core::command::render] Encoding render pass begin in command buffer (0, 3, Gl)
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl::device] create_framebuffer [Renderbuffer(1)]
[2020-03-02T03:56:52Z TRACE wgpu_core::command::bind]   Binding [0] = group (0, 1, Gl)
[2020-03-02T03:56:52Z TRACE wgpu_core::command::bind]           binding up to 1
[2020-03-02T03:56:52Z DEBUG wgpu_core::command] Command buffer (0, 3, Gl) TrackerSet {
        buffers: {
            (
                3,
                1,
            ): Unit {
                first: None,
                last: UNIFORM,
            },
            (
                0,
                1,
            ): Unit {
                first: None,
                last: VERTEX,
            },
            (
                1,
                1,
            ): Unit {
                first: None,
                last: INDEX,
            },
        },
        textures: {
            (
                0,
                1,
            ): TextureState {
                mips: [
                    RangedStates {
                        ranges: [
                            (
                                0..1,
                                Unit {
                                    first: None,
                                    last: SAMPLED,
                                },
                            ),
                        ],
                    },
                ],
                full: false,
            },
        },
        views: {
            (
                0,
                1,
            ): PhantomData,
        },
        bind_groups: {
            (
                0,
                1,
            ): PhantomData,
        },
        samplers: {
            (
                0,
                1,
            ): PhantomData,
        },
    }
[2020-03-02T03:56:52Z TRACE wgpu_core::device] Stitching command buffer (0, 3, Gl) before submission
[2020-03-02T03:56:52Z DEBUG wgpu_core::device] Device after submission 4: TrackerSet {
        buffers: {
            (
                3,
                1,
            ): Unit {
                first: Some(
                    MAP_WRITE,
                ),
                last: UNIFORM,
            },
            (
                0,
                1,
            ): Unit {
                first: Some(
                    MAP_WRITE,
                ),
                last: VERTEX,
            },
            (
                4,
                1,
            ): Unit {
                first: Some(
                    MAP_WRITE,
                ),
                last: COPY_SRC,
            },
            (
                1,
                1,
            ): Unit {
                first: Some(
                    MAP_WRITE,
                ),
                last: INDEX,
            },
        },
        textures: {
            (
                0,
                1,
            ): TextureState {
                mips: [
                    RangedStates {
                        ranges: [
                            (
                                0..1,
                                Unit {
                                    first: Some(
                                        COPY_DST,
                                    ),
                                    last: SAMPLED,
                                },
                            ),
                        ],
                    },
                ],
                full: true,
            },
        },
        views: {
            (
                0,
                1,
            ): PhantomData,
        },
        bind_groups: {
            (
                0,
                1,
            ): PhantomData,
        },
        samplers: {
            (
                0,
                1,
            ): PhantomData,
        },
    }
[2020-03-02T03:56:52Z TRACE wgpu_core::device::life] Active submission 3 is done
[2020-03-02T03:56:52Z ERROR gfx_backend_gl] [API/Error] ID 1 : GL_INVALID_FRAMEBUFFER_OPERATION in glBlitFramebuffer(incomplete draw/read buffers)
[2020-03-02T03:56:52Z TRACE wgpu_core::command::allocator] recycling comb submitted in 3 when 4 is lowest active
[2020-03-02T03:56:52Z TRACE wgpu_core::command::render] Encoding render pass begin in command buffer (0, 4, Gl)
[2020-03-02T03:56:52Z DEBUG gfx_backend_gl::device] create_framebuffer [Renderbuffer(1)]
thread 'main' panicked at 'Error creating FBO: InvalidFramebufferOperation for RenderPass { attachments: [Attachment { format: Some(Bgra8Srgb), samples: 1, ops: AttachmentOps { load: Clear, store: Store }, stencil_ops: AttachmentOps { load: DontCare, store: DontCare }, layouts: Undefined..Present }], subpasses: [SubpassDesc { color_attachments: [0], depth_stencil: None }] }', <::std::macros::panic macros>:5:6
stack backtrace:
   0:     0x5639707f3934 - backtrace::backtrace::libunwind::trace::h9f3df88002326b1d
                               at /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
   1:     0x5639707f3934 - backtrace::backtrace::trace_unsynchronized::hc3b79a9fda5a6ced
                               at /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66
   2:     0x5639707f3934 - std::sys_common::backtrace::_print_fmt::h793e307f54fbed3f
                               at src/libstd/sys_common/backtrace.rs:78
   3:     0x5639707f3934 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::haf78f81924d25977
                               at src/libstd/sys_common/backtrace.rs:59
   4:     0x56397081b71c - core::fmt::write::hd372270af18e073d
                               at src/libcore/fmt/mod.rs:1052
   5:     0x5639707efc77 - std::io::Write::write_fmt::h2ea0baf47bb32c1e
                               at src/libstd/io/mod.rs:1428
   6:     0x5639707f6675 - std::sys_common::backtrace::_print::h530c568555e4ed47
                               at src/libstd/sys_common/backtrace.rs:62
   7:     0x5639707f6675 - std::sys_common::backtrace::print::h7b814989f558f3a6
                               at src/libstd/sys_common/backtrace.rs:49
   8:     0x5639707f6675 - std::panicking::default_hook::{{closure}}::h65678be373d64a54
                               at src/libstd/panicking.rs:204
   9:     0x5639707f63b6 - std::panicking::default_hook::he72803f3a45e7e59
                               at src/libstd/panicking.rs:224
  10:     0x5639707f6cd2 - std::panicking::rust_panic_with_hook::h2ca68d7da273625b
                               at src/libstd/panicking.rs:470
  11:     0x5639707f68bb - rust_begin_unwind
                               at src/libstd/panicking.rs:378
  12:     0x5639707f682b - std::panicking::begin_panic_fmt::ha0d34e5d0ca155a7
                               at src/libstd/panicking.rs:332
  13:     0x56397000ac3d - <gfx_backend_gl::device::Device as gfx_hal::device::Device<gfx_backend_gl::Backend>>::create_framebuffer::{{closure}}::h0f46806113f8abd7
                               at /home/zicklag/git/other/wgpu/wgpu-native/<::std::macros::panic macros>:5
  14:     0x56396fe98fb7 - core::iter::adapters::map_fold::{{closure}}::h7397ca0caea7a69e
                               at /rustc/61d9231ff2604a0467987042d9ebf9ff9ea739b5/src/libcore/iter/adapters/mod.rs:772
  15:     0x56396fed0121 - core::iter::traits::iterator::Iterator::fold::ok::{{closure}}::hb21d50753297fc3d
                               at /rustc/61d9231ff2604a0467987042d9ebf9ff9ea739b5/src/libcore/iter/traits/iterator.rs:2000
  16:     0x56396fd48780 - core::iter::traits::iterator::Iterator::try_fold::h264ee017e52733eb
                               at /rustc/61d9231ff2604a0467987042d9ebf9ff9ea739b5/src/libcore/iter/traits/iterator.rs:1876
  17:     0x56396fd45bf3 - core::iter::traits::iterator::Iterator::fold::hf96b8f290f9fb621
                               at /rustc/61d9231ff2604a0467987042d9ebf9ff9ea739b5/src/libcore/iter/traits/iterator.rs:2003
  18:     0x56396fea0c60 - <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold::ha14eb19d136328b5
                               at /rustc/61d9231ff2604a0467987042d9ebf9ff9ea739b5/src/libcore/iter/adapters/mod.rs:812
  19:     0x56396fe902df - core::iter::traits::iterator::Iterator::for_each::hedb3376fef33e3c0
                               at /rustc/61d9231ff2604a0467987042d9ebf9ff9ea739b5/src/libcore/iter/traits/iterator.rs:659
  20:     0x563970060fa2 - <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::spec_extend::h79fb12f704d0fcd7
                               at /rustc/61d9231ff2604a0467987042d9ebf9ff9ea739b5/src/liballoc/vec.rs:2056
  21:     0x56397006a691 - <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter::hd8655131940ac0e9
                               at /rustc/61d9231ff2604a0467987042d9ebf9ff9ea739b5/src/liballoc/vec.rs:2036
  22:     0x5639700787ec - <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter::hb7746f7aa67b6ac8
                               at /rustc/61d9231ff2604a0467987042d9ebf9ff9ea739b5/src/liballoc/vec.rs:1921
  23:     0x56396fe8ccbb - core::iter::traits::iterator::Iterator::collect::he5d9bf4ac27a5754
                               at /rustc/61d9231ff2604a0467987042d9ebf9ff9ea739b5/src/libcore/iter/traits/iterator.rs:1658
  24:     0x563970009d56 - <gfx_backend_gl::device::Device as gfx_hal::device::Device<gfx_backend_gl::Backend>>::create_framebuffer::h40a7da2b93a51b18
                               at /home/zicklag/git/other/gfx/src/backend/gl/src/device.rs:995
  25:     0x56396ff4a073 - wgpu_core::command::render::<impl wgpu_core::hub::Global<F>>::command_encoder_run_render_pass::h182f5e0aa5485e01
                               at /home/zicklag/git/other/wgpu/wgpu-core/src/command/render.rs:661
  26:     0x56396fee8675 - wgpu_render_pass_end_pass
                               at /home/zicklag/git/other/wgpu/wgpu-native/src/command.rs:93
  27:     0x56396fd401e1 - <wgpu::RenderPass as core::ops::drop::Drop>::drop::h92b36f1edf956b17
                               at src/lib.rs:1378
  28:     0x56396fb1e8fb - core::ptr::drop_in_place::hd261e7857dac0343
                               at /rustc/61d9231ff2604a0467987042d9ebf9ff9ea739b5/src/libcore/ptr/mod.rs:174
  29:     0x56396faef287 - <cube::Example as cube::framework::Example>::render::hb0628dbeefd89861
                               at examples/cube/main.rs:357
  30:     0x56396faf16c2 - cube::framework::run::{{closure}}::h8438d814ae30ce1e
                               at examples/cube/../framework.rs:175
  31:     0x56396fad5c73 - winit::platform_impl::platform::sticky_exit_callback::h0bd205be0bf81b02
                               at /home/zicklag/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.20.0/src/platform_impl/linux/mod.rs:697
  32:     0x56396fb16e7d - winit::platform_impl::platform::x11::EventLoop<T>::run_return::h883d82bcc63e9550
                               at /home/zicklag/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.20.0/src/platform_impl/linux/x11/mod.rs:290
  33:     0x56396fb182cb - winit::platform_impl::platform::x11::EventLoop<T>::run::h64af203ee7dd2271
                               at /home/zicklag/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.20.0/src/platform_impl/linux/x11/mod.rs:386
  34:     0x56396fad599e - winit::platform_impl::platform::EventLoop<T>::run::h8d0b9662af1fdce1
                               at /home/zicklag/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.20.0/src/platform_impl/linux/mod.rs:644
  35:     0x56396fb16064 - winit::event_loop::EventLoop<T>::run::hfaa98eafbdb722c0
                               at /home/zicklag/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.20.0/src/event_loop.rs:148
  36:     0x56396faf0fc2 - cube::framework::run::h9ce2c72ea8b1890b
                               at examples/cube/../framework.rs:133
  37:     0x56396faef2d5 - cube::main::h7ffb4d91a362a58e
                               at examples/cube/main.rs:364
  38:     0x56396fb1314b - std::rt::lang_start::{{closure}}::hb5600e360cf425a5
                               at /rustc/61d9231ff2604a0467987042d9ebf9ff9ea739b5/src/libstd/rt.rs:67
  39:     0x5639707f6793 - std::rt::lang_start_internal::{{closure}}::h50b0398997fe4311
                               at src/libstd/rt.rs:52
  40:     0x5639707f6793 - std::panicking::try::do_call::h85d26496c32350c5
                               at src/libstd/panicking.rs:303
  41:     0x5639707ff887 - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:86
  42:     0x5639707f7179 - std::panicking::try::hfbb56b98b87a45a4
                               at src/libstd/panicking.rs:281
  43:     0x5639707f7179 - std::panic::catch_unwind::h794130e368adf375
                               at src/libstd/panic.rs:394
  44:     0x5639707f7179 - std::rt::lang_start_internal::h628c81c720c4941a
                               at src/libstd/rt.rs:51
  45:     0x56396fb13127 - std::rt::lang_start::ha3ec210e91cb762d
                               at /rustc/61d9231ff2604a0467987042d9ebf9ff9ea739b5/src/libstd/rt.rs:67
  46:     0x56396faef30a - main
  47:     0x7f49ce630b6b - __libc_start_main
  48:     0x56396fab102a - _start
  49:                0x0 - <unknown>
[2020-03-02T03:56:52Z TRACE wgpu_core::device::life] Active submission 4 is done

@kvark
Copy link
Member

kvark commented Mar 2, 2020

There is a blit happening, and it complains that one of the framebuffers is incomplete. First of all, I would assume that your code path does not need a blit. With your surface implementation, rendering to a swapchain should be direct, no copies/blits involved.

@zicklag
Copy link
Contributor Author

zicklag commented Mar 3, 2020

OK, I found out where the blit is:

gl.blit_framebuffer(
0,
0,
extent.width as _,
extent.height as _,
0,
0,
extent.width as _,
extent.height as _,
glow::COLOR_BUFFER_BIT,
glow::LINEAR,
);
}
#[cfg(all(feature = "glutin", not(target_arch = "wasm32")))]
swapchain.context.swap_buffers().unwrap();

It is probably erroring because I do not have a swap buffers call for surfman and I don't know how to do that. I haven't looked into it yet.

But, you did say that you don't think there should be any copying anyway. Is there a way around using the blit in this case?

@kvark
Copy link
Member

kvark commented Mar 3, 2020

Here is how OpenGL allows one to render a frame: you draw framebuffer(0), and you render, done.

Here is how gfx-rs allows one to render a frame: you get the next image, then you have/create a view into it, then you create a framebuffer that includes that view. That framebuffer can include other views as well, such as your manially depth texture. Then you execute a render pass that renders into that framebuffer.

If we don't blit, we would require that if a framebuffer contains the swapchain image (in GL), it has to have nothing else. This is not what users expect... So instead, we create a render buffer internally, render into it, and then when it's time to present - we blit into the GL framebuffer(0).

That blit is costy and highly unfortunate. However, surfman approach gives us hope. Looking at https://docs.rs/surfman/0.1.3/surfman/platform/unix/x11/surface/struct.SurfaceTexture.html for example, I see that gl_texture() just returns a texture ID. That means we can expose it to the users as regular Backend::Image types, and have framebuffers mixing them with other images. Which in turn means that we can finally remove the blit.

Needless to say, you are unravelling one hack in GL after another, and it's sadly all connected. Requires heroic effort to defeat, but Rust community will be very happy :)

@zicklag
Copy link
Contributor Author

zicklag commented Mar 3, 2020

Thanks for the explanation and the help. I'm glad we've gotten this far. :)

I'll try to process that and look around and show you what I come up with.

@kvark kvark changed the title Wgpu gl support OpenGL surface via surfman Mar 4, 2020
Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the default features being our last change, it would be great to try taking the quad example from hal-0.5 branch, moving it out, and compiling with "GL" feature against your modified code. This will require glutin to be enabled by default - it's fine for hal-0.5, since any user can pass --no-default-features. If it doesn't work at all, well, that's not the end of the world, we'll just make sure to release 0.6 sooner :)

- Re-order dependencies in examples Cargo.toml
- Make sure that GL is tested in reftests
- Remove cfg_aliases `use` from `build.rs`
- Make surfman take precedence over glutin when both features are
  enabled.
- Remove unused winit dependency
- Only include winapi when using the `wgl` feature
- Take out DEPTH and STENCIL flags from GL context
- Remove unnecessary drop() call
- Remove unneeded GL `cfg_attr`'s from warden
@zicklag
Copy link
Contributor Author

zicklag commented Apr 12, 2020

Unfortunately I just found that the reftests are segfaulting for GL and the makefile wasn't testing GL on CI properly.

I'll have to look into that. I just pushed a commit that addresses all of the points of the review and additionally allows you to run with both the glutin and the surfman features enabled with surfman taking precedence on Linux. This lets you use glutin on Windows and surfman on Linux if you preferred glutin for Windows over wgl.


As the default features being our last change, it would be great to try taking the quad example from hal-0.5 branch, moving it out, and compiling with "GL" feature against your modified code.

I'll try that out.


Edit: Oh, servo/surfman#172 just got merged, too, so I'll update the surfman dependency to point at that commit instead of my branch.

@zicklag
Copy link
Contributor Author

zicklag commented Apr 12, 2020

For some reason it is segfaulting right here:

let value = unsafe { gl.get_parameter_string(name) };

It is when it tries to get the vendor name from the GL context. There it isn't happening when running the quad example, but it will happen if you re-order the creation of the surface and the enumeration of the adapters.

Any clue what might cause that?

@kvark
Copy link
Member

kvark commented Apr 12, 2020 via email

@zicklag
Copy link
Contributor Author

zicklag commented Apr 12, 2020

Ah, thank you, that is definitely the cause.

Apparently I was just getting lucky with the fact that it happened to be working with the order that the current quad and wgpu examples were running certain functions. Now I'm having a little bit of trouble, but I'm not necessarily stuck yet.

The problem is that when I try to run make_current on the context whenever the GlContainer is dreferenced, it just renders a blank screen for some reason. When I don't make current on dereference it errors out somewhere along the line ( unless you get lucky, like I did ealier ) and I need to figure out all of the places in the code I need to make current now. Hopefully that won't be too difficult.

Fixes a segfault that could happen when enumerating adapters and fixed
the issue where only one adapter could be listed.
@zicklag
Copy link
Contributor Author

zicklag commented Apr 13, 2020

@kvark I found out where to put the make_context_current call to fix the error, but I'm not 100% sure it is the best spot to put it:

fn supports_queue_family(&self, _: &QueueFamily) -> bool {
self.make_context_current();
true
}

It is the earliest spot that I could find after enumerating adapters that has access to the specific surface that needs to be made current. I tried sticking it in configure_swapchain which is where I felt that it should go, but it panics with an invalid command error.

It seems like maybe we should be making the context current on de-reference, but I still don't know how to fix the black screen that happens when we do that, and I don't know how to go about debugging it. I feel like we can leave it for now and fix it later.


The reftests aren't segfaulting anymore but they are hitting unimplemented!() for Device::create_query_pool(). Do we just leave that for now?

Also, CI isn't set to run the reftests, but there is a Makefile entry specifically for CI reftests. Does that need to be added to the Travis config?

@zicklag
Copy link
Contributor Author

zicklag commented Apr 13, 2020

I just tested the following steps and got the quad and colour-uniform examples working on hal-0.5:

  1. switch to this PR's branch
  2. rebase onto hal-0.5
  3. Change the default features of gfx-backend-gl to [] like it was before the PR ( it turns out it wasn't actually glutin before this PR ) , to avoid making a breaking change
  4. Update the gfx-backend-gl dependency to include the features = ["wgl", "surfman", "surfman-x11"]
  5. Run the examples

So as long as I'm not missing something other than the default features that makes this change breaking, I think we can safely backport it to 0.5!

@kvark
Copy link
Member

kvark commented Apr 13, 2020

@zicklag what happens if the example tries to use the glutin feature like it does today?

Re-adds some "unused" re-exports that were removed in the surfman
update. Other than the default features, this makes the surfman update
backward compatible with `hal-0.5`.
@zicklag
Copy link
Contributor Author

zicklag commented Apr 14, 2020

Ah, I get it now, we want to test the old examples to make sure that they still work as a validation of the fact that our changes are still backward compatible. 👍

I tested it and, good news! The examples work without changes after the latest commit I made to re-add some "unused" imports/exports in the glutin implementation.

That means that the only difference that will be necessary for the backport and the master commit will be to make sure the default features and examples stay unchanged from hal-0.5 for the backported version. 🌟 Piece of 🍰.

@kvark
Copy link
Member

kvark commented Apr 14, 2020

That's wonderful!
So where do we stand now? Are there known issues blocking the merge at this point?

@zicklag
Copy link
Contributor Author

zicklag commented Apr 14, 2020

Not that I know of. Some things such as when the context gets made current might not be technically correct or work in all cases, but that is kind of the story with the whole backend right now. 😉

I think its ready. If we notice anything else after we can make follow-up PRs.

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work, thank you!
bors r+

@bors
Copy link
Contributor

bors bot commented Apr 14, 2020

Build succeeded:

@bors bors bot merged commit deeb135 into gfx-rs:master Apr 14, 2020
@kvark
Copy link
Member

kvark commented Apr 14, 2020

@zicklag would you want to follow-up with a PR to hal-0.5 that has this code with the default features fixed?

@zicklag
Copy link
Contributor Author

zicklag commented Apr 14, 2020

Yeah, I can probably have that PR ready by tonight.

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

Successfully merging this pull request may close these issues.

5 participants