szeged / webrender

A GPU-based renderer for the web
https://doc.servo.org/webrender/
Mozilla Public License 2.0
45 stars 7 forks source link

Match passes in WR with render passes in the native API #269

Open kvark opened 5 years ago

kvark commented 5 years ago

Currently, we are starting a pass for each slice of the WR pass, so that we can select the render target. This incurs a lot of overhead, since switching a render pass is heavy.

What we could do in Metal, on some hardware, is binding the whole array as a destination, and selecting the target slice in the vertex shader:

typedef struct {
    float4 position [[position]];
    uint layer [[render_target_array_index]];
} ClearVertexData;

vertex ClearVertexData vs_clear(ClearAttributes in [[stage_in]]) {
    float4 pos = { 0.0, 0.0, in.coords.z, 1.0f };
    pos.xy = in.coords.xy * 2.0 - 1.0;
    return ClearVertexData { pos, uint(in.coords.w) };
}

How exactly this would map to Vulkan, or the gfx-hal API, is another question. But in theory, we should be able to make it fast on Metal, at least.

@jrmuizel

kvark commented 5 years ago

The solution appears to be straightforward - https://github.com/gfx-rs/gfx/issues/2720