gpu,gpu/headless,app/internal/wm: add explicit RenderTarget API

Both the OpenGL and the Direct3D API are stateful and gpu.GPU renders to
the render target current when Frame is called.

Modern GPU API such as Metal don't have a concept of a current render
target, and the target even changes each frame.

Add RenderTarget and add an explicit target argument to GPU.Frame as
well as the underlying driver.Device.BeginFrame.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-08-04 14:10:07 +02:00
parent 0bdc2e0432
commit 7d84e419c9
16 changed files with 95 additions and 23 deletions
+1 -1
View File
@@ -174,7 +174,7 @@ func newDriver(t *testing.T) driver.Device {
if err != nil {
t.Fatal(err)
}
b.BeginFrame(true, image.Pt(1, 1))
b.BeginFrame(nil, true, image.Pt(1, 1))
t.Cleanup(func() {
b.EndFrame()
ctx.ReleaseCurrent()
+1 -1
View File
@@ -112,7 +112,7 @@ func (w *Window) Frame(frame *op.Ops) error {
w.dev.BindFramebuffer(w.fbo)
w.gpu.Clear(color.NRGBA{})
w.gpu.Collect(w.size, frame)
return w.gpu.Frame()
return w.gpu.Frame(driver.RenderTarget(w.fbo))
})
}