gpu: introduce render passes

Modern GPU API such as Metal and Vulkan use explicit render passes
and command buffers for recording rendering commands. They don't have
global state; each render pass starts with a clean set of bound
textures, pipeline etc.

Change our GPU abstraction to better match newer API and modify our two
renderers to explicitly describe their render passes.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-09-03 10:05:35 +02:00
parent af6770de18
commit cc2edbaa51
9 changed files with 252 additions and 228 deletions
+6 -7
View File
@@ -7,6 +7,7 @@ import (
"image"
"time"
"gioui.org/internal/f32color"
"gioui.org/shader"
)
@@ -34,9 +35,10 @@ type Device interface {
DrawArrays(mode DrawMode, off, count int)
DrawElements(mode DrawMode, off, count int)
BeginRenderPass(f Framebuffer, desc LoadDesc)
EndRenderPass()
BindProgram(p Program)
BindPipeline(p Pipeline)
BindFramebuffer(f Framebuffer, a LoadDesc)
BindTexture(unit int, t Texture)
BindVertexBuffer(b Buffer, offset int)
BindIndexBuffer(b Buffer)
@@ -45,6 +47,8 @@ type Device interface {
BindFragmentUniforms(buf Buffer)
BindStorageBuffer(binding int, buf Buffer)
BeginCompute()
EndCompute()
CopyTexture(dst Texture, dstOrigin image.Point, src Framebuffer, srcRect image.Rectangle)
MemoryBarrier()
DispatchCompute(x, y, z int)
@@ -54,12 +58,7 @@ type Device interface {
type LoadDesc struct {
Action LoadAction
ClearColor struct {
R float32
G float32
B float32
A float32
}
ClearColor f32color.RGBA
}
type Pipeline interface {