forked from joejulian/gio
gpu/internal/driver: get rid of Device.MemoryBarrier
MemoryBarrier is meant to stand in for OpenGL ES 3.1's glMemoryBarrier. However, it badly fits with the other backends: Metal and D3D11 have automatic memory barriers, and Vulkan needs barriers for graphics as well. This change removes MemoryBarrier, and puts the burden on the backends. The OpenGL backend simply adds a barrier between every compute dispatch. This change only adds a single memory barrier compared to the manual barriers before this change, which is unlikely to affect performance much.. We can revisit the automatic barriers if they ever become a performance problem. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+1
-3
@@ -1340,9 +1340,7 @@ func (g *compute) render(images *textureAtlas, dst driver.Texture, cpuDst cpu.Im
|
||||
}
|
||||
|
||||
func (g *compute) memoryBarrier() {
|
||||
if !g.useCPU {
|
||||
g.ctx.MemoryBarrier()
|
||||
} else {
|
||||
if g.useCPU {
|
||||
g.dispatcher.Barrier()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -591,8 +591,6 @@ func (b *Backend) BindImageTexture(unit int, tex driver.Texture) {
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Backend) MemoryBarrier() {}
|
||||
|
||||
func (b *Backend) DispatchCompute(x, y, z int) {
|
||||
b.ctx.CSSetShader(b.program.shader)
|
||||
b.ctx.Dispatch(uint32(x), uint32(y), uint32(z))
|
||||
|
||||
@@ -49,7 +49,6 @@ type Device interface {
|
||||
BeginCompute()
|
||||
EndCompute()
|
||||
CopyTexture(dst Texture, dstOrigin image.Point, src Texture, srcRect image.Rectangle)
|
||||
MemoryBarrier()
|
||||
DispatchCompute(x, y, z int)
|
||||
|
||||
Release()
|
||||
|
||||
@@ -818,8 +818,6 @@ func (b *Backend) BindImageTexture(unit int, tex driver.Texture) {
|
||||
b.BindTexture(unit, tex)
|
||||
}
|
||||
|
||||
func (b *Backend) MemoryBarrier() {}
|
||||
|
||||
func (b *Backend) BeginCompute() {
|
||||
b.endEncoder()
|
||||
b.ensureCmdBuffer()
|
||||
|
||||
@@ -760,10 +760,6 @@ func (b *Backend) Release() {
|
||||
*b = Backend{}
|
||||
}
|
||||
|
||||
func (b *Backend) MemoryBarrier() {
|
||||
b.funcs.MemoryBarrier(gl.ALL_BARRIER_BITS)
|
||||
}
|
||||
|
||||
func (b *Backend) DispatchCompute(x, y, z int) {
|
||||
for binding, buf := range b.storage {
|
||||
if buf != nil {
|
||||
@@ -771,6 +767,7 @@ func (b *Backend) DispatchCompute(x, y, z int) {
|
||||
}
|
||||
}
|
||||
b.funcs.DispatchCompute(x, y, z)
|
||||
b.funcs.MemoryBarrier(gl.ALL_BARRIER_BITS)
|
||||
}
|
||||
|
||||
func (b *Backend) BindImageTexture(unit int, tex driver.Texture) {
|
||||
@@ -1157,6 +1154,7 @@ func (b *Backend) BindPipeline(pl driver.Pipeline) {
|
||||
}
|
||||
|
||||
func (b *Backend) BeginCompute() {
|
||||
b.funcs.MemoryBarrier(gl.ALL_BARRIER_BITS)
|
||||
}
|
||||
|
||||
func (b *Backend) EndCompute() {
|
||||
|
||||
Reference in New Issue
Block a user