mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 16:35:36 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user