graphicsdriver/metal: Bug fix: Sync textures before replacing a region

Updates #1213
This commit is contained in:
Hajime Hoshi 2020-06-27 03:03:53 +09:00
parent 7b6182d05a
commit 2bc1475a15
3 changed files with 5 additions and 6 deletions

View File

@ -440,7 +440,7 @@ func (g *Graphics) NewImage(width, height int) (driver.Image, error) {
Width: graphics.InternalImageSize(width), Width: graphics.InternalImageSize(width),
Height: graphics.InternalImageSize(height), Height: graphics.InternalImageSize(height),
StorageMode: storageMode, StorageMode: storageMode,
Usage: textureUsage, Usage: mtl.TextureUsageShaderRead | mtl.TextureUsageRenderTarget,
} }
var t mtl.Texture var t mtl.Texture
g.t.Call(func() error { g.t.Call(func() error {
@ -873,6 +873,10 @@ func (i *Image) ReplacePixels(args []*driver.ReplacePixelsArgs) {
if g.drawCalled { if g.drawCalled {
g.flush(true, false) g.flush(true, false)
g.drawCalled = false g.drawCalled = false
// When mtl.TextureUsageRenderTarget is specified, synchronizing the texture memory before replacing
// a region seems necessary (#1213).
i.syncTexture()
} }
g.t.Call(func() error { g.t.Call(func() error {

View File

@ -58,8 +58,6 @@ func (v *view) update() {
} }
const ( const (
textureUsage = mtl.TextureUsageShaderRead | mtl.TextureUsageRenderTarget
storageMode = mtl.StorageModeShared storageMode = mtl.StorageModeShared
resourceStorageMode = mtl.ResourceStorageModeShared resourceStorageMode = mtl.ResourceStorageModeShared
) )

View File

@ -46,9 +46,6 @@ func (v *view) update() {
} }
const ( const (
// MTLTextureUsageRenderTarget might cause a problematic render result. Not sure the reason.
textureUsage = mtl.TextureUsageShaderRead
storageMode = mtl.StorageModeManaged storageMode = mtl.StorageModeManaged
resourceStorageMode = mtl.ResourceStorageModeManaged resourceStorageMode = mtl.ResourceStorageModeManaged
) )